xml - 逻辑应用程序中的 XPath 根据其类型提取值
问题描述
我正在使用逻辑应用程序来剖析和重建入站 XML。我遇到的问题是 XML 的一部分并不总是以相同的顺序与相同数量的小节。所以我想知道是否可以根据类型返回值?即在此示例中,我想返回值 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
将选择 的元素的所有Value
子Context
元素Type
test2
。
推荐阅读
- bash - 在 Cloud Run 上部署基于 bash 的服务器:如何修复 502 Bad gateway 错误?
- html - 即使内容更高的卡体,大小和宽度相同
- robotframework - RobotFramework - 同一过程中测试用例中的顺序步骤
- amazon-web-services - 与本地模板化不一致的条件结果类型
- javascript - Leaflet 是否能够映射 +200,000 个标记?
- python - Python C 扩展间接级别
- ios - 如何在 IOS react native 上接收推送通知?
- html - Blazor 将字段设为只读
- python - 从具有多列的 CSV 中的字典列创建数据框
- docker - Docker - FROM 需要来自 spyder 的一个或三个参数错误