title: Get node parent of defined type using xpath
body: <p>i will give an example of the problem i have. My XML is like this</p>
  
  <pre><code>&lt;root&gt;
    &lt;child Name = "child1"&gt;
    &lt;node&gt;
    &lt;element1&gt;Value1&lt;/element1&gt;
    &lt;element2&gt;Value2&lt;/element2&gt;
    &lt;/node&gt;
    &lt;/child&gt;
    &lt;child Name = "child2"&gt;
    &lt;element1&gt;Value1&lt;/element1&gt;
    &lt;element2&gt;Value2&lt;/element2&gt;
    &lt;element3&gt;Value3&lt;/element3&gt;
    &lt;/child&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I have xpath expression that returns all "element2" nodes. Then i want to for every node of type "element2" to find the node of type "child" that contains it. The problem is that between these two nodes there can be from 1 to n different nodes so i can't just use "..". Is there something like "//" that will look up instead of down<br></p>
  
  <p>I have some basic knowledge of xpath and according <a href="http://www.w3schools.com/xpath/xpath_syntax.asp" rel="nofollow noreferrer">http://www.w3schools.com/xpath/xpath_syntax.asp</a> "..' returns current node parent the problem is that the current node is "element2" and the problem is that the xml is dynamic comes from third party library so i can have xml like this </p>
  
  <pre><code>&lt;child Name = "child1"&gt;
    &lt;node&gt;
    &lt;element1&gt;Value1&lt;/element1&gt;
    &lt;/node&gt;
  &lt;/child&gt;
  </code></pre>
  
  <p>or like this</p>
  
  <pre><code>&lt;child Name = "child1"&gt;
    &lt;node1&gt;
     &lt;node2&gt;
      &lt;node3&gt;
       &lt;element1&gt;Value1&lt;/element1&gt;
       &lt;element2&gt;Value2&lt;/element2&gt;
      &lt;/node3&gt;
     &lt;/node2&gt;
    &lt;/node1&gt;
  &lt;/child&gt;
  </code></pre>
  
  <p>There can be more then 3 nodes between "element" and child an the number of nodes vary form 1 to 20. Please give me an example of just one xpath query to get the "child" node in both cases using just ".." </p>
  
  <p>Best Regards,<br>
  Iordan</p>