title: Can I use SimpleXML & Xpath to directly select an Elements Attribute?
body: <p>i.e. - i want to return a string "yellow" using something like xpath expression "//banana/@color" and the following example xml...</p>
  
  <pre><code>&lt;fruits&gt;
   &lt;kiwi color="green" texture="hairy"/&gt;
   &lt;banana color="yellow" texture="waxy"/&gt;
  &lt;/fruits&gt;
  
  
  $fruits = simplexml_load_string(
  '&lt;fruits&gt;
   &lt;kiwi color="green" texture="hairy"/&gt;
   &lt;banana color="yellow" texture="waxy"/&gt;
  &lt;/fruits&gt;');
  
  print_r($fruits-&gt;xpath('//banana/@color'));
  </code></pre>
  
  <p>produces</p>
  
  <pre><code>Array
  (
      [0] =&gt; SimpleXMLElement Object
          (
              [@attributes] =&gt; Array
                  (
                      [color] =&gt; yellow
                  )
  
          )
  
  )
  </code></pre>
  
  <p>whereas i would prefer something like...</p>
  
  <pre><code>Array
  (
      [0] =&gt; SimpleXMLElement Object
          (
              [0] =&gt; yellow
          )
  
  )
  </code></pre>
  
  <p>...so that i don't need to write a special case into the application i'm writing.</p>
  
  <p>thanks very much! :)</p>