逻辑应用程序中的 XPath,用于根据其类型提取值

XPath in a logic app to extract a value based on its type

我正在使用逻辑应用程序来剖析和重建入站 XML。我遇到的问题是 XML 的一部分并不总是具有相同数量的小节。所以我想知道是否可以 return 基于类型的值?也就是说,在此示例中,我想 return 值 2,其中 2 并不总是第二个上下文。

 <ContextCollection>
  <Context>
    <Type>test1</Type>
    <Value>1</Value>
  </Context>
  <Context>
    <Type>test2</Type>
    <Value>2</Value>
  </Context>
  <Context>
    <Type>test3</Type>
    <Value>3</Value>
  </Context>

我已经成功使用了下面的表达式xpath(xml(variables('XMLStripNameSpace')),'string(/*[name()="ContextCollection"]/*[name()="Context"][2]/*[name()="Value"])')

但是当test2是第三个时,这显然不起作用Context

这个 XPath,

//Context[Type = "test2"]/Value

将 select Type test2.

Context 个元素的所有 Value 个子元素