I am trying to parse an XML file using PHP in order to find an attribute value.
The XML appears as follows(example.xml):
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<xryfile XRYVersion="6.11.1.0">
<images>
<image type="PHYSICAL" id="0" version="6.11.1">
<views>
<view type="location_history_view">
<nodes>
<node>
<properties>
<property type="application">Facebook Messenger</property>
<property type="longitude">-1.000000</property>
<property type="latitude">1.000000</property>
</properties>
</node>
</nodes>
</view>
</views>
</image>
</images>
</xryfile>
I wish to extract the values of the "property" nodes but I am unsure of the syntax to use to extract this information.
I have tried the following code:
<?php
$xml = simplexml_load_file('example.xml');
foreach($xml->property[0]->attributes() as $a) {
echo $a;
}
?>
I can work out how to extract a node easily if the node was say:
<property>Facebook Messenger</property>
However I am having trouble working out how to extract attribute values when it appears like this:
<property type="application">Facebook Messenger</property>
I would very much appreciate some help with the problem as I have been stuck for a while now.
Thanks in advance :)