php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48504 document_element contains nothing
Submitted: 2009-06-09 10:48 UTC Modified: 2009-06-09 10:55 UTC
From: ikrabbe dot ask at web dot de Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
 [2009-06-09 10:48 UTC] ikrabbe dot ask at web dot de
Description:
------------
on
$xml="<a><b>abc</b><c/></a>";
$xmldoc = new DOMDocument();
$xmldoc->loadXML($xml);
I get for
echo "item 0=".$xmldoc->childNodes->item(0)->nodeName."\n";
echo "root =".$xmldoc->document_element->nodeName."\n";
the output:
item 0=a
root=
I assumed that document_element should be the same as childNodes->item(0), so I assume that is a bug.


Reproduce code:
---------------
see above

Expected result:
----------------
see above

Actual result:
--------------
see above

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-09 10:53 UTC] ikrabbe dot ask at web dot de
Actually:
if ( !$xmldocu->document_element )
  echo "NULL Document";
reveals a NULL root node !  Thats actually a bug.  Please either correct this behaviour or describe whats meant by "document_element" in the documentation.
 [2009-06-09 10:55 UTC] ikrabbe dot ask at web dot de
Sorry, I misspelled the item: document_element is called documentElement.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Dec 03 08:01:23 2020 UTC