<?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"); }