日期:2014-05-17 浏览次数:20767 次
<?xml version="1.0" encoding="utf-8" ?>
<test>
<item id="totid">0</item>
<item id="totid1">1</item>
<item id="totid2">2</item>
<item id="totid3">3</item>
<item id="totid4">4</item>
</test>
string path = @"H:\DavidTest\DavidMeeting\test.xml";
XElement root = XElement.Load(path);
var searchObj = from ele in root.Elements("item").Attributes("id")
where ele.Value == "totid"
select ele.Parent;