您的位置首页百科问答

C#对XML的操作

C#对XML的操作

的有关信息介绍如下:

C#对XML的操作

C#对于XML文件的简单操作

引用包:

using System.Xml;

using System.IO;

解释:

其中Xml包为xml文件操作的封装。

IO是文件的读写操作包。

//新建xml对象

xml = new XmlDocument();

//加入声明

xml.AppendChild(xml.CreateXmlDeclaration("1.0", "UTF-8", null));

//加入根元素

xml.AppendChild(xml.CreateElement("Root"));

//保存到路径

SaveXML(xml, Path);