我正在尝试加载具有多个命名空间声明的 XML 文档我的 php 是:
<?php
$doc = new DOMDocument('1.0','UTF-8');
$doc->load( 'UBLCatalog.xml' );
$Items = $doc->getElementsByTagNameNS( "UBLCommonAggregateComponents","Item" );
foreach( $Items as $Item )
{
$descriptions = $Item->getElementsByTagNameNS( "UBLCommonBasicComponents","Description" );
$description = $descriptions->item(0)->nodeValue;
echo "<b>$description\n</b><br>";
}
?>
错误是:
xmlns:URI UBLDatalogDocument 在 file:///C:/wamp/www/XMLExperiments/UBLCatalog.xml 中不是绝对的,
我得到了输出,但这个错误很烦人。
逐字记录错误是: 注意:DOMDocument::load() [domdocument.load]: xmlns: URI ULCatalogDocument is not absolute in file:///C:/wamp/www/XMLExperiments/UBLCatalog.xml, line: 4 in C :\wamp\www\XMLExperiments\ItemsXml.php 在第 3 行
而且,如果我删除默认命名空间 (xmlns="UBLDatalogDocument"),错误就会消失