php檔案
複製程式碼程式碼如下:
class xpathExtension{
class xpathExtension{
public static f. ($domDoc, $xpathString) {
$xp = new DOMXPath($domDoc);
$xp->registerNamespace('x', 'http://www.w3.org/1999/xhtml') ;
$xp->registerNamespace('xhtml', 'http://www.w3.org/1999/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);
}
回傳$ret;
}
}
$domDoc = new DOMDocument();
$domDoc-> load("x1.xml");
$xpathString = "//xml/products/product/description";
$domNodeList = xpathExtension::getNodes($domDoc, $xpathString);
/path//回顯計數($domNodeList);
foreach($domNodeList as $domNode){
echo $domNode->nodeValue;
xml
複製程式碼
程式碼如下:
;
;
abcd
描述>
產品>
以上就介紹了export_symbol php讀取xml實例程式碼,包含了export_symbol方面的內容,希望對PHP教學有興趣的朋友有幫助。