测试通过,要在linq中加上命名空间限制:
<?xml version="1.0" encoding="utf-8" ?>
<dataOperations xmlns="http://www.gasgoo.com/DataOperation">
<dataOperation id="1">
<name>abc</name>
<password>123</password>
</dataOperation>
<dataOperation id="2">
<name>def</name>
<password>123</password>
</dataOperation>
</dataOperations >
程序:
XDocument xmlFile = XDocument.Load(@"E:\NET\AlbumExe\AlbumExe\test.xml");
IEnumerable<XElement> awElements = from el in xmlFile.Descendants()
where el.Name.Namespace == "http://www.gasgoo.com/DataOperation"
select el;
foreach (XElement el in awElements)
MessageBox.Show(el.Value.ToString());
给分吧,哈哈!!!
楼主请给出具体是怎样操作的