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