栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 人工智能 > NLP

xml学习(4) 创建xml 文件

NLP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

xml学习(4) 创建xml 文件

xml学习(4) 创建xml 文件

  ///     /// 创建一个xml文件    ///     /// 文件名字    private void createXmlDoc(string fileName)    {      string  row=  System.Environment.newline;          Xmldocument xmlDoc = new Xmldocument();        XmlDeclaration xde  ;//表示 XML 声明节点:        xde = xmlDoc.CreateXmlDeclaration("1.0", "ISO-8859-1", null);//verson:1.0 encoding:utf-8  standalone:yes(表示独立的,不依赖别的文件)        xmlDoc.AppendChild(xde);        XmlElement root = xmlDoc.CreateElement("BOOKS");        root.SetAttribute("name", "根级元素");        xmlDoc.AppendChild(root);        XmlElement node1 = xmlDoc.CreateElement("BOOK");        root.AppendChild(node1);        XmlElement node11 = xmlDoc.CreateElement("AUTHOR");        node11.InnerText = "XMROOM";        node1.AppendChild(node11);        XmlElement node12 = xmlDoc.CreateElement("NAME");        node12.InnerText = "编程你最爱";        node1.AppendChild(node12);        XmlElement node13 = xmlDoc.CreateElement("TIME");        node13.InnerText = "2013-11-20";        node1.AppendChild(node13);        XmlElement node14 = xmlDoc.CreateElement("COPYRIGHT");        node14.InnerText = "XMROOM";        node1.AppendChild(node14);        string path = Server.MapPath("Xml\") + fileName + ".xml";        if (File.Exists(path))        {            File.Delete(path);                    }        xmlDoc.Save(path);    }

以上就是xml学习(4) 创建xml 文件的内容,更多相关内容请关注PHP中文网(www.kaotop.com)!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/794782.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号