【发布时间】:2009-04-06 14:05:10
【问题描述】:
给定一个 Xml 如下所示。我将如何编写 XPATH 查询来获取“key”值具有特定值(比如 2)的“leaf2”子项的值
我正在使用 C# .NET。目前,我只是在寻找使用 SelectNodes 获取密钥的 Xpath,找到正确的值然后导航回 leaf2。
<root>
<child>
<anotherChild>
<key>1</key>
</anotherChild>
<leaf1>X</leaf1>
<leaf2>Y</leaf2>
<leaf3></leaf3>
</child>
<child>
<anotherChild>
<key>2</key>
</anotherChild>
<leaf1>A</leaf1>
<leaf2>B</leaf2>
<leaf3></leaf3>
</child>
</root>
【问题讨论】: