title: XPath in a logic app to extract a value based on its type
body: <p>I am using a logic app to dissect and reconstruct an inbound XML. The problem that I am having is that a portion of the XML is not always in the same order with the same amount of subsections. So I am wondering if it was possible to return the value based on the type? I.e in this example I want to return the value 2 where 2 is not always the second context.</p>
  
  <pre><code> &lt;ContextCollection&gt;
    &lt;Context&gt;
      &lt;Type&gt;test1&lt;/Type&gt;
      &lt;Value&gt;1&lt;/Value&gt;
    &lt;/Context&gt;
    &lt;Context&gt;
      &lt;Type&gt;test2&lt;/Type&gt;
      &lt;Value&gt;2&lt;/Value&gt;
    &lt;/Context&gt;
    &lt;Context&gt;
      &lt;Type&gt;test3&lt;/Type&gt;
      &lt;Value&gt;3&lt;/Value&gt;
    &lt;/Context&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have successfully used the following expression <code>xpath(xml(variables('XMLStripNameSpace')),'string(/*[name()="ContextCollection"]/*[name()="Context"][2]/*[name()="Value"])')</code> </p>
  
  <p>but this obviously does not work when the test2 is the third <code>Context</code>.</p>