【发布时间】:2016-12-01 14:38:11
【问题描述】:
这是我的 XML..
<rootparent>
<root>
...other nodes here.
...
<parent>
<child id="child_1">
.some other nodes ..
</child>
<child id="child_2">
.some other nodes ..
</child>
...other nodes
</parent>
</root>
</rootparent>
我需要使用 LINQ to XML select all the child nodes where id like 'child_%'。
我得到了这个的 xpath
string xPath="/root/parent/child[id='child_*']";
var x1 =xml.XPathSelectElement(xPath);
var x2 = _sourceDoc.Root.XPathEvaluate(xPath);
但它返回Enumeration yielded no results。
【问题讨论】:
-
这可能会有所帮助 - stackoverflow.com/questions/18891206/…
-
我需要使用 XPath,我试图使其通用。@Asnivor
标签: c# xml xpath linq-to-xml