yami_rider
asked on
Get Root Node using DOMDocument in PHP 5
I am trying to get the root node of this XML using DOMDocument in PHP 5.
<diagnosis xmlns="http://checkout.google.com/schema/2" serial-number="8088c57b-bf 00-4e83-b2 d7-df9767d a9140">
<input-xml>
<checkout-shopping-cart>
<shopping-cart>
</shopping-cart>
<checkout-flow-support>
</checkout-flow-support>
</checkout-shopping-cart>
</input-xml>
</diagnosis>
The root of the document should be "diagnosis" my code looks like this:
$dom_response = new DOMDocument();
$boolresult = $dom_response->loadXML($di agnose_res ponse);
$root_element = $dom_response->getDocument Element;
$root_tag = $root_element->tagname;
The loadXML function returns TRUE, but when I call the property getDocumentElement it returns NULL.
How would I go about getting the document root of the XML supplied?
<diagnosis xmlns="http://checkout.google.com/schema/2" serial-number="8088c57b-bf
<input-xml>
<checkout-shopping-cart>
<shopping-cart>
</shopping-cart>
<checkout-flow-support>
</checkout-flow-support>
</checkout-shopping-cart>
</input-xml>
</diagnosis>
The root of the document should be "diagnosis" my code looks like this:
$dom_response = new DOMDocument();
$boolresult = $dom_response->loadXML($di
$root_element = $dom_response->getDocument
$root_tag = $root_element->tagname;
The loadXML function returns TRUE, but when I call the property getDocumentElement it returns NULL.
How would I go about getting the document root of the XML supplied?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window