考虑以下 XML:
<SomeRoot>
<SomeElement>
<SomeThing>25</SomeThing>
<SomeOther>Cat</SomeOther>
</SomeElement>
<SomeElement>
<SomeThing>46</SomeThing>
<SomeOther>Dog</SomeOther>
</SomeElement>
<SomeElement>
<SomeThing>83</SomeThing>
<SomeOther>Bat</SomeOther>
</SomeElement>
<SomethingElse>Unrelated to the SomeElements above</SomethingElse>
</SomeRoot>
我想select SomeThing where SomeOther = 'Cat'
。以下 C# 代码引发空引用异常:
xmlDoc = new XmlDocument();
this.path = path;
// Path is passed elsewhere
Console.WriteLine(xmlDoc.SelectSingleNode("/SomeRoot/SomeElement/SomeThing[../SomeOther='Cat']").InnerText);
在这里使用的正确 XPath 语法是什么?