My xml file example.xml is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<Declaration>
<ID>345678</ID>
<TransID>1473909194263</TransID>
<Time>2016-02-24T22:13:15</Time>
<Groups>
<Group>
<Name>Aaron</Name>
<SelectedFields/>
</Group>
</Groups>
<Scores/>
<RelatedVariables>
<RelatedVariable dataType="Number">
<Value>5555</Value>
</RelatedVariable>
<RelatedVariable dataType="Number">
<Value>9999</Value>
</RelatedVariable>
</RelatedVariables>
</Declaration>
My php code as follows:
$xml=simplexml_load_file("example.xml") or die("Error: Cannot create object");
echo $xml->ID; //Gives 345678
echo $xml->Groups->Group->Name; // Gives Group->Name rather than Aaron
Question :
When I used PHP simplexml_load_file method to get the value $xml->ID
by the above code it gave 345678. But when I tried to get the value of
$xml->Groups->Group->Name the parser confused and gave
Group->Name rather than giving Aaron. The parser confuse with
Groups and Group I think. Whats the correct code to get the Name Aaron