Hello i am trying to parse nested xml but i am using multiple for loops to extact but i dont find it very proper way.
I want to parse data based on unique id and separte them but cant figure any easy way to that
here is my xml
<propertyList date="2014-06-02-17:30:33" username="adsss" password="v147C0z5CBlw">
<business modTime="2014-06-02-12:22:32" status="current">
<agentID>TEST</agentID>
<uniqueID>1420648</uniqueID>
<listingAgent id="1">
<name>jonny</name>
<telephone type="BH"></telephone>
<telephone type="mobile"></telephone>
<email>aT@cs.com.au</email>
</listingAgent>
<listingAgent id="2"></listingAgent>
</business>
<business modTime="2014-05-16-15:11:41" status="current">
<agentID>TEST</agentID>
<uniqueID>1435201</uniqueID>
<listingAgent id="1">
<name>Mike Smith</name>
<telephone type="BH"></telephone>
<telephone type="mobile"></telephone>
<email>acebrokers@bs.com.au</email>
</listingAgent><listingAgent id="2"></listingAgent>
</business>
</propertyList>
Here is my code
<?php
$xml=simplexml_load_file("myxmldata.xml");
echo "<pre>";
for($i=0;$i<count($xml);$i++):
echo "agentID=>".$xml->business[$i]->agentID;
echo "<br>";
echo "uniqueID=>".$xml->business[$i]->uniqueID;
echo "<br>";
endfor;
for($i=0;$i<count($xml->business->listingAgent);$i++):
echo "agentName=>".$xml->business->listingAgent[$i]->name;
endfor;
for($i=0;$i<count($xml->business->listingAgent->telephone);$i++):
echo "telephonetype=>".$xml->business->listingAgent->telephone[$i]->type;
endfor;
?>