I have an XML file which I receive by post.
<response>
<id>D234>/id>
<Logs>
<time>UTC</time>
<Alarms>
</Alarms>
</Logs>
</response>
Sometimes it may have few alarm logs
<response>
<id>D234>/id>
<Logs>
<time>UTC</time>
<Alarms>
<Log>
<LD>Reset </LD>
<utc>1383704429</utc>
</Log>
<Log>
<LD>Triggered </LD>
<utc>1383601449</utc>
</Log>
</Alarms>
</Logs>
</response>
I want to check if <Alarms> has children, and then form a query to insert them into db.
I tried xpath. I can find if children are there or not, and I can count. no problem.
$xml = simplexml_load_string(POST_DATA);
$alarms = $xml->xpath('Logs/Alarms');
echo count($alarms);
But how can traverse through each of the log? so that I can form a query to enter into DB. I am at a loss.
eg: how can I get Log0->time?