title: How to query a xml file using xpath (php) ?
body: <p>I am trying to query an XML file using XPath. But as return I get nothing. I think I formatted the query false. </p>
  
  <blockquote>
    <p>XML</p>
  </blockquote>
  
  <pre><code>&lt;subject id="Tom"&gt;
     &lt;relation unit="ITSupport" role="ITSupporter" /&gt;
    &lt;/subject&gt;
  </code></pre>
  
  <blockquote>
    <p>PHP </p>
  </blockquote>
  
  <pre><code>$xpath = new DOMXpath($doc);
              $role = 'ITSupporter';
             $elements = $xpath-&gt; query("//subject/@id[../relation/@role='".$role."']");              
             foreach ($elements as $element) {    
                $name = $element -&gt; nodeValue;
                $arr[$i] = $name;
                $i = $i + 1;
             }    
  </code></pre>
  
  <p>How can I get the id TOM? I want to save it to for example $var</p>