C# XDocument

时间:2020-07-03 15:22:41   收藏:0   阅读:86

XDocument

说明LINQ处理XML文件的一个类
添加引用

using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
引用xml文件
XDocument xml = XDocument.Load("IOS.xml");
根节点
XElement root = xml.Root;

xml查询

要记得引用 using System.Xml.XPath;

 xml.Root.XPathSelectElement("//XCUIElementTypeApplication");
foreach (XElement item in xml.Elements())
{
   //xml中的属性都在里面
   c.Attributes()
}

XElement

XDocument代表xml文档,Xelement则代表具体的某个元素节点
获取属性XElement.Attribute(属性名)

获取属性集合XElement.Attributes(属性名)

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!