码迷,mamicode.com
首页 > Windows程序 > 详细

C#XML操作详解

时间:2016-02-22 16:46:59      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

添加引用

using System.Xml;

 创建XML文件

XmlDocument xmldoc=new XmlDocument();
//加入XML的声明段落:<?xmlversion="1.0" encoding="utf-8"?>
XmlDeclaration xmldecl=xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
xmldoc.AppendChild(xmldecl);
//保存创建好的XML文档
xmldoc.Save(@"D:\user.xml");

 创建节点

//创建根节点
XmlElement xmlroot = xmlDoc.CreateElement("user");
xmlDoc.AppendChild(xmlroot);

 

C#XML操作详解

标签:

原文地址:http://www.cnblogs.com/Sandon/p/5207442.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!