#47612 [Opn->Bgs]: DOM Xml seems broken when used with DTD
ID: 47612
Updated by: chregu@php.net
Reported By: murlock42 at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Linux Debian Lenny
PHP Version: 5.3CVS-2009-03-10 (snap)
New Comment:
The root node is always at
$xml->documentElement and not always at $xml->firstChild.
Change that and your problem should be slved
Previous Comments:
------------------------------------------------------------------------
[2009-03-10 08:39:07] murlock42 at gmail dot com
The url for the XML files :
http://murlock.org/file_with_dtd.xml
http://murlock.org/file_without_dtd.xml
Thanks,
------------------------------------------------------------------------
[2009-03-10 08:36:14] murlock42 at gmail dot com
Description:
------------
When I use a XML file with DTD, the root node doesn't have any children
(but xpath query works) and if I removed the DTD, the DOM seems ok
Reproduce code:
---------------
function test( $filename ) {
$xml = new DOMDocument();
$xml->load( $filename, LIBXML_NOBLANKS );
echo "\n$filename\n";
echo "Root of XML : " . $xml->firstChild->nodeName . "\n";
echo "First child of XML Root : " .
$xml->firstChild->firstChild->nodeName . "\n";
$xpath = new DOMXpath( $xml );
echo "result of /mame/game xpath query : \n";
$r = $xpath->query("/mame/game");
for( $i=0; $i<$r->length; $i++ ) {
echo $r->item($i)->nodeName . "\n";
}
}
test( "file_without_dtd.xml" );
test( "file_with_dtd.xml" );
Expected result:
----------------
with the two XML files:
file_without_dtd.xml
Root of XML : mame
First child of XML Root : game
result of /mame/game xpath query :
game
file_with_dtd.xml
Root of XML : mame
First child of XML Root : game
result of /mame/game xpath query :
game
Actual result:
--------------
file_without_dtd.xml
Root of XML : mame
First child of XML Root : game
result of /mame/game xpath query :
game
file_with_dtd.xml
Root of XML : mame
First child of XML Root :
result of /mame/game xpath query :
game
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47612&edit=1
Thread (4 messages)