日期:2014-05-20 浏览次数:20915 次
<?xml version="1.0" encoding="utf-8" ?> <table> <record id="1" name="aa" age="10"/> <record id="2" name="bb" age="20"/> <record id="3" name="cc" age="30"/> <record id="4" name="dd" age="40"/> <record id="5" name="ee" age="50"/> </table>
var xdoc = XDocument.Load("xml文件路径"); var record = xdoc.Descendants("record").First(x => x.Attribute("id").Value == "3");
------解决方案--------------------
<?xml version="1.0" encoding="utf-8" ?> <table> <record id="1" name="aa" age="10"/> <record id="2" name="bb" age="20"/> <record id="3" name="cc" age="30"/> <record id="4" name="dd" age="40"/> <record id="5" name="ee" age="50"/> </table>