创建xml文件的代码分享

今天小编给大家分享的是创建xml文件的代码,很多人都不太了解,今天小编为了让大家更加了解创建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文件的代码的简略介绍,当然详细使用上面的不同还得要大家自己使用过才领会。如果想了解更多,欢迎关注创新互联行业资讯频道哦!


网页题目:创建xml文件的代码分享
当前地址:http://bzwzjz.com/article/ppooji.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站设计公司 成都网站建设公司 企业网站设计 营销网站建设 成都网站设计 成都响应式网站建设 重庆网站制作 营销网站建设 高端网站建设 网站设计制作报价 公司网站建设 手机网站建设 重庆外贸网站建设 成都网站建设 响应式网站设计 做网站设计 成都网站设计 四川成都网站制作 成都企业网站设计 网站制作公司 高端网站设计 重庆手机网站建设