title: how to specify the index of text to be matched in xpath query
body: <p>I have a xml file <a href="http://pastebin.com/YgpZJhHC" rel="nofollow">xml</a> and i need to parse it. What i want to do is to get the last position of tag script based on the previous input.</p>
  
  <p>my previous input will be the 2nd position of the tag script (say - networkSecurity, sdnSTC)</p>
  
  <p>so how can I specify the index of the text to be matched in the xquery.</p>
  
  <p>the code that I am using now is - </p>
  
  <pre><code>   &lt;?php
  
      $variable=$_POST['module']; 
      $xmldoc = new DOMDocument();
              $xmldoc-&gt;load('info.xml');
  
              $xpathvar = new Domxpath($xmldoc);
  
      $queryResult = $xpathvar-&gt;query("testcase[contains(script,'$variable')]"); 
  
              foreach($queryResult as $result)
              {
                      echo $result-&gt;textContent;
              }
  
      ?&gt; 
  </code></pre>
  
  <p>here in this $queryResult how I can specify that the index of the $variable is 2 ?</p>