這是我的XML內蒙古XML節點..選擇包含幾乎相同的ID
<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>
我需要select all the child nodes where id like 'child_%'
使用LINQ to XML。
我得到了XPath的這一
string xPath="/root/parent/child[id='child_*']";
var x1 =xml.XPathSelectElement(xPath);
var x2 = _sourceDoc.Root.XPathEvaluate(xPath);
但它返回Enumeration yielded no results
。
這可能會幫助 - http://stackoverflow.com/questions/18891206/parse-xml-with-linq-to-get-child-elements – Asnivor
我需要使用XPath,我試圖使它generic。@ Asnivor –