ID:               47612
 User updated by:  murlock42 at gmail dot com
 Reported By:      murlock42 at gmail dot com
 Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Linux Debian Lenny
 PHP Version:      5.3CVS-2009-03-10 (snap)
 New Comment:

Ok, it's work with documentElement, 
I found doc unclear: instead of 'This is a convenience attribute that
allows direct access to the child node that is the document element of
the document.', the doc should be something like that 'User must use
this to access to the child node that is the document element of the
document.'

But now, I've another weird problem (bug ? or my fault ?) with DTD : 


function test( $filename ) {
  $xml = new DOMDocument();
  $xml->load( $filename, LIBXML_NOBLANKS );

  $node = $xml->documentElement->firstChild;

  if ( $node->attributes->getNamedItem("isbios") )
    echo $node->attributes->getNamedItem("isbios")->nodeValue . "\n";
  else
    echo "no attribute isbios\n";
}
test( "file_without_dtd.xml" );
test( "file_with_dtd.xml" );

:

no attribute isbios

Warning: DOMNamedNodeMap::getNamedItem(): Unsupported node type: 16 in
/home/murlock/perso/mameutils/bad.php on line 9
no attribute isbios


Previous Comments:
------------------------------------------------------------------------

[2009-03-10 15:08:21] [email protected]

The root node is always at

$xml->documentElement and not always at $xml->firstChild.

Change that and your problem should be slved





------------------------------------------------------------------------

[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

Reply via email to