title: How to find element in specific context using DOMXPath in php?
body: <p>I'm trying to parse a xml file with information about some users. Something like this</p>
  
  <p><strong>users.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;users&gt;
      &lt;user&gt;
          &lt;name&gt;Alexander&lt;/name&gt;
          &lt;email&gt;alexander@test.com&lt;/email&gt;
      &lt;/user&gt;
      &lt;user&gt;
          &lt;name&gt;Tyler&lt;/name&gt;
          &lt;email&gt;tyler@test.com&lt;/email&gt;
      &lt;/user&gt;
  &lt;/users&gt;
  </code></pre>
  
  <p>I'm using <code>DOMXpath</code> to extract all users inside this xml, and all of this fields. 
  In xml file, I have 15 users and when I search all fields about one user in this code </p>
  
  <pre><code>$username = $xpath-&gt;query ( '//email', $users-&gt;item(0) );
  </code></pre>
  
  <p>I got 15 length, instead of 1. I mean <code>query</code> is searching in all xml instead of looking for the actual user. 
  What I'm doing wrong? </p>
  
  <p><strong>xml_query.php</strong></p>
  
  <pre><code>$xml = new DOMDocument();
  $xml-&gt;loadXML( $xml_content );
  $xpath = new DOMXPath($xml);
  
  $users = $xpath-&gt;query( '//user' );
  var_dump( $users-&gt;item(0) );
  $username = $xpath-&gt;query ( '//email', $users-&gt;item(0) );
  
  var_dump( $username );
  </code></pre>