title: PHP DOM XPath - Get child elements AND self (using query with contextnode)
body: <p>Using this XML for example...</p>
  
  <pre><code>&lt;test&gt;
    &lt;tag0&gt;
      &lt;tag1 is="mine"&gt;
          &lt;uselesstag&gt;
              &lt;tag3 is="mine"&gt;test&lt;/tag3&gt;
          &lt;/uselesstag&gt;
      &lt;/tag1&gt;
      &lt;tag2 is="mine"&gt;test2&lt;/tag2&gt;
    &lt;/tag0&gt;
  &lt;/test&gt;
  </code></pre>
  
  <p>... and getting an element for a contextnode (a contextnode is required)</p>
  
  <pre><code>$dom = new DomDocument;
  $dom-&gt;loadXML($xml);
  $xpath = new DomXPath($dom);
  $context = $xpath-&gt;query("//tag1")-&gt;item(0);
  </code></pre>
  
  <p>... how can I get a nodelist containing any contextnode children <b>and including self contextnode</b> that attribute "is" is equal to "mine"? For example: I just want to get the tag1 and tag3 elements (tag1 is the contextnode)</p>
  
  <pre><code>$res = $xpath-&gt;query('.//*[@is="mine"]',$context);
  </code></pre>
  
  <p>In this case, only tag3 (child) is available on the nodelist.</p>
  
  <pre><code>$res = $xpath-&gt;query('..//*[@is="mine"]',$context);
  </code></pre>
  
  <p>In this case, tag1 (contextnode), tag3 (child) and tag2 (sibling) is available on the nodelist.</p>