您的位置:首页 > 编程语言 > C#

C#_添加xml文件

2015-09-14 17:57 639 查看
引用:System.Xml;

System.Xml.XmlDocument xml = new System.Xml.XmlDocument();

System.Xml.XmlDeclaration dec = xml.CreateXmlDeclaration("1.0", "UTF-8", null);
xml.AppendChild(dec);
System.Xml.XmlElement ele = xml.CreateElement("A");
xml.AppendChild(ele);
System.Xml.XmlElement ele2 = xml.CreateElement("B");

System.Xml.XmlAttribute xa = xml.CreateAttribute("C");
xa.Value = "D";
ele2.Attributes.Append(xa);
ele2.InnerXml= "E";
ele.AppendChild(ele2);

xml.Save(Server.MapPath("~/1.xml"));


View Code
学习网站:http://www.bccn.net/Article/web/xml/


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: