title: Find element with attribute - SimpleXML xpath
body: <p>I'm trying to select an element from my xml with a particular attribute 'id'.
  This is my xml:</p>
  
  <pre><code>&lt;listitems&gt;
    &lt;item id="1"&gt;
      &lt;name&gt;item 1&lt;/name&gt;
    &lt;/item&gt;
    &lt;item id="2"&gt;
      &lt;name&gt;item 2&lt;/name&gt;
    &lt;/item&gt;
    &lt;item id="3"&gt;
      &lt;name&gt;item 3&lt;/name&gt;
    &lt;/item&gt;
  &lt;/listitems&gt;
  </code></pre>
  
  <p>This the php file:</p>
  
  <pre><code>&lt;?php
  $simplexml = simplexml_file_load('test.xml');
  $item = $simplexml-&gt;xpath('item[@id="1"]');
  ?&gt;
  </code></pre>
  
  <p>Then if I try, for example:</p>
  
  <pre><code>&lt;?php $item-&gt;addchild('description','textdescription'); ?&gt;
  </code></pre>
  
  <p>I get on the last line this error:
  "Fatal error: Call to a member function addchild() on a non-object"</p>
  
  <p>Is there anything wrong?</p>