日期:2014-05-17 浏览次数:20822 次
<?xml version="1.0" encoding="gbk"?>
<Data>
<cfg Name="闂ㄩ攣1">
<_0920>
<t>0022</t>
<hw>1500</hw>
<io>0</io>
</_0920>
</cfg>
<cfg Name="璇诲崱鍣?">
<_00E0>
<t>0023</t>
<ni>0001</ni>
<bi>0060</bi>
<rt>01</rt>
<mid>01</mid>
<ce>00000000</ce>
</_00E0>
</cfg>
</Data>
var query = xdc.Descendants("Data").DescendantsAndSelf().Where(x=>x.Name.ToString().StartsWith("_"));
int i=0;
var xmlDoc = LoadXmlDoc(@"test.xml");
var anyExpr = "//*[starts-with(name(),'_')]"; // 选取所有含"_"的节点
var anyNodes = GetXmlNodes(xmlDoc, anyExpr);
Console.WriteLine("XPath表达式为 //_,共有:" + anyNodes.Count);
foreach (var item in anyNodes)
{
Console.WriteLine(item.ToString());
for (i = 0; i < anyNodes.Count; i++)
{
Console.WriteLine(anyNodes[i].InnerXml);
}
}