【发布时间】:2012-06-14 18:14:24
【问题描述】:
我正在尝试加载具有多个命名空间声明的 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 UBLDatalogDocument is not absolute in file:///C:/wamp/www/XMLExperiments/UBLCatalog.xml, line: 4 在 C:\wamp\www\XMLExperiments\ItemsXml.php 第 3 行
而且,如果我删除默认命名空间 (xmlns="UBLCatalogDocument"),错误就会消失
【问题讨论】:
-
你能把XML格式分享在这里给别人看看。有助于理解结构。
-
是哪一行导致了这个错误?
标签: php xml namespaces