title: xpath query on SimpleXML Document - Undefined offset: 0
body: <p>I'm quite new to SimpleXML and using xpath within it. I wasn't sure whether to post this query within the original posting or here, so I linked to here form the original posting.</p>
  
  <p>In working through several test scripts, I came across this <a href="https://stackoverflow.com/questions/9696545/simplexml-get-node-child-based-on-attribute">posting</a>, and I've been attempting to make one of the accepted answers work.
  However, when I attempt to use the xpath version of the accepted answer work, I get the error message:</p>
  
  <pre><code>Undefined offset: 0 
  </code></pre>
  
  <p>I've tested xpath in other ways, to verify that it is installed and functional.  Thanks for any leads.</p>
  
  <p>I have duplicated the OP's xml file, along with the accepted answer code:</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;data&gt;
    &lt;poster name="E-Verify" id="everify"&gt;
      &lt;full_image url="e-verify-swa-poster.jpg"/&gt;
      &lt;full_other url=""/&gt;
    &lt;/poster&gt;
    &lt;poster name="Minimum Wage" id="minwage"&gt;
      &lt;full_image url="minwage.jpg"/&gt;
      &lt;full_other url="spa_minwage.jpg"/&gt;
    &lt;/poster&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>&lt;?php
  $url = "test_b.xml";
  $xml = simplexml_load_file($url);
  $main_url = $xml-&gt;xpath('name[@id="minwage"]/full_image')[0];
  ?&gt;
  </code></pre>