title: xpath finding out what child number is amongst other siblings
body: <p>I've had several other question related to the subject:</p>
  
  <p><a href="https://stackoverflow.com/questions/14007344/getting-a-parent-node-and-its-child-where-the-child-has-a-certain-text">getting a parent node and its child, where the child has a certain text</a></p>
  
  <p>and 
  <a href="https://stackoverflow.com/questions/14012564/xpath-finding-certain-node-with-certain-text">XPath finding certain node with certain text</a></p>
  
  <p>Lets say this is my HTML:</p>
  
  <pre><code>&lt;body&gt;
      &lt;div&gt;
            &lt;span&gt;something else&lt;/span&gt;
            &lt;span&gt;something&lt;/span&gt;
            &lt;span&gt;something else&lt;/span&gt;
      &lt;div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I am using the following to query for a node with certain text:</p>
  
  <p><code>$node_with_value = $xpath-&gt;query('(//*[text()= "'something"])');</code></p>
  
  <p>this returns the list with all node that has something.
  In this case it will be only 1.</p>
  
  <p>to find its parent i do:
  <code>parent = $node_with_value-&gt;item(0)-&gt;parentNode;</code></p>
  
  <p>Now my question is how can i check what number of child it is.</p>
  
  <p>in the above we have 3 span children to the div, counting from top to bottom its number 2. is there a way to count that programmaticaly?</p>