I have the following XML file (below) and i’d like to get a hook on the name of the root node.
I’ve tried the following:
$config = simplexml_load_string($xml_data);
echo $config->getName();
Which echo’s nothing. I’ve also iterated over the result but it starts at the children of the root node
foreach($config as $key => $value)
{
echo $key;
}
// echo's ReturnStatus, SearchURL and PropertyResults
I just want the name of the root node “SearchResponse”. I can’t seem to find anything in the SimpleXMLElement class documentation that’ll help http://www.php.net/manual/en/class.simplexmlelement.php
<?xml version="1.0" encoding="ISO-8859-1" ?>
<SearchResponse>
<ReturnStatus>
<Success>
<data>true</data>
<data2>true</data2>
</Success>
<Success>
<data>false</data>
<data2>true</data2>
</Success>
<Exception />
</ReturnStatus>
<SearchURL />
<PropertyResults>
<PropertyResult>
<PropertyID>1468830</PropertyID>
<PropertyName>Sands Acapulco</PropertyName>
</PropertyResult>
<PropertyResult>
<PropertyID>1353302</PropertyID>
<PropertyName>Acapulco Turquesa</PropertyName>
</PropertyResult>
<PropertyResult>
<PropertyID>4521565</PropertyID>
<PropertyName>Almaria Delsonto</PropertyName>
</PropertyResult>
</PropertyResults>
</SearchResponse>
This does work:
Tested with the XML you provided, Output:
You write it would not work, so probably the issue is not the API.