PHP5: Find Root Node in DOMDocument PHP5: Find Root Node in DOMDocument xml xml

PHP5: Find Root Node in DOMDocument


DOMElement extends DOMNode.

You get the Root DOMElement by $d->documentElement.


DOM Model- The W3C has broken down the DOM into a tree structure of nodes of varying types. The Node interface is the base interface for all elements. All objects implementing this interface expose methods for dealing with children.

$dom=new DomDocument;$dom->Load("file.xml");$root=$dom->documentElement; // Root node


According to the PHP docs DOMElement is a subclass of DOMNode, so it should inherit the hasChildNodes()-method.