C# XDocument


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查询

  • Xpath查询【推荐方法】

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

 xml.Root.XPathSelectElement("//XCUIElementTypeApplication");
  • LINQ 查询
  • 遍历Elements然后对比文本或其他属性
foreach (XElement item in xml.Elements())
{
   //xml中的属性都在里面
   c.Attributes()
}

XElement

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

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM