• C# 创建xml


    <?xml version="1.0" encoding="UTF-8"?>
    <swUpgrade xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.645#utranNrm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.3gpp.org/ftp/specs/archive/32_series/32.645#utranNrm swUpgrade.xsd">
      <contentBlock>
        <compatibleALDs>
          <compatibilityInformation>
            <vendorCode>VR</vendorCode>
            <aldType>aldType</aldType>
            <productNumber>productNumber</productNumber>
            <swVersion>swVersion</swVersion>
            <hwVersion>hwVersion</hwVersion>
          </compatibilityInformation>
        </compatibleALDs>
        <sw>VG9uZ1l1MTRSQ1UyLjEuMAAAAAAAAAAAAAAAAAAAAACYCwAgiSEACG03</sw>
      </contentBlock>
    </swUpgrade>
     private void CreateXML(string xmlFilePath)
            {
                string xmlnsAttr= "http://www.3gpp.org/ftp/specs/archive/32_series/32.645#utranNrm";
                string xmlnsXsiAttr = "http://www.w3.org/2001/XMLSchema-instance";
                string xsiSchemaLocAttr = "http://www.3gpp.org/ftp/specs/archive/32_series/32.645#utranNrm swUpgrade.xsd";
    
                XmlDocument xmlDoc = new XmlDocument();
                //加入XML的声明段落
                xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null));
    
               // swUpgrade
                XmlElement swUpgradeElement = xmlDoc.CreateElement("swUpgrade");
                swUpgradeElement.SetAttribute("xmlns", xmlnsAttr);
                swUpgradeElement.SetAttribute("xmlns:xsi", xmlnsXsiAttr);
                swUpgradeElement.SetAttribute("xsi:schemaLocation", xsiSchemaLocAttr);
                xmlDoc.AppendChild(swUpgradeElement);
    
                    //contentBlock
                    XmlNode contentBlockNode = xmlDoc.CreateElement("contentBlock");
    
                        //compatibleALDs
                        XmlNode compatibeALDsNode = xmlDoc.CreateElement("compatibleALDs");
    
                            //compatibilityInformation
                            XmlNode informationNode = xmlDoc.CreateElement("compatibilityInformation");
                                XmlElement vendorCodeElement = xmlDoc.CreateElement("vendorCode");
                                vendorCodeElement.InnerText = "VR";
                                XmlElement aldTypeElement = xmlDoc.CreateElement("aldType");
                                aldTypeElement.InnerText = "aldType";
                                XmlElement productNumberElement = xmlDoc.CreateElement("productNumber");
                                productNumberElement.InnerText = "productNumber";
                                XmlElement swVersionElement = xmlDoc.CreateElement("swVersion");
                                swVersionElement.InnerText = "swVersion";
                                XmlElement hwVersionElement = xmlDoc.CreateElement("hwVersion");
                                hwVersionElement.InnerText = "hwVersion";
    
                               informationNode.AppendChild(vendorCodeElement);
                               informationNode.AppendChild(aldTypeElement);
                               informationNode.AppendChild(productNumberElement);
                               informationNode.AppendChild(swVersionElement);
                               informationNode.AppendChild(hwVersionElement);
                       compatibeALDsNode.AppendChild(informationNode);
    
                   contentBlockNode.AppendChild(compatibeALDsNode);
    
                   XmlNode swNode = xmlDoc.CreateElement("sw"); ;
                   swNode.InnerText = "VG9uZ1l1MTRSQ1UyLjEuMAAAAAAAAAAAAAAAAAAAAACYCwAgiSEACG03";
    
                   contentBlockNode.AppendChild(swNode);
                swUpgradeElement.AppendChild(contentBlockNode);
                xmlDoc.Save(@"d:	est.xml");
    
            }
  • 相关阅读:
    高并发 内核优化
    mysql 读写分离
    Jmeter使用入门
    Jenkins+Jmeter+Ant接口持续集成
    Android客户端稳定性测试——Monkey
    SVN客户端项目递归删除.svn目录
    Windows 下 php5+apache+mysql5 手工搭建笔记
    熟悉常用的Linux操作
    C语言文法
    词法分析实验报告
  • 原文地址:https://www.cnblogs.com/ike_li/p/5881361.html
Copyright © 2020-2023  润新知