Php reads the xml instance code. For more information, see.
Php file
The code is as follows:
Class xpathExtension {
Public static function getNodes ($ domDoc, $ xpathString ){
$ Xp = new DOMXPath ($ domDoc );
$ Xp-> registerNamespace ('X', 'http: // www.w3.org/5o/xhtml ');
$ Xp-> registerNamespace ('xhtml ', 'http: // www.w3.org/5o/xhtml ');
$ Xp-> registerNamespace ('i18n', 'http: // apache.org/cocoon/i18n/2.1 ');
$ Ret = array ();
$ Nodes = $ xp-> query ($ xpathString );
Foreach ($ nodes as $ node ){
Array_push ($ ret, $ node );
}
Return $ ret;
}
}
$ DomDoc = new DOMDocument ();
$ DomDoc-> load ("x1.xml ");
$ XpathString = "// xml/products/product/description ";
$ DomNodeList = xpathExtension: getNodes ($ domDoc, $ xpathString );
// Echo count ($ domNodeList );
Foreach ($ domNodeList as $ domNode ){
Echo $ domNode-> nodeValue;
}
?>
Xml
The code is as follows:
Abcd