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:\test.xml"); }
c# 创建xml的更多相关文章
- .net中xml文件的导入使用(包括创建xml和导入xml)
上次有说到.net 创建xml文件的方法(一种固定方式,一种动态方法),这次记录一下怎样导入xml文件 1.导入xml文件的方法 1)xml文件格式
- .net中创建xml文件的两种方法
.net中创建xml文件的两种方法 方法1:根据xml结构一步一步构建xml文档,保存文件(动态方式) 方法2:直接加载xml结构,保存文件(固定方式) 方法1:动态创建xml文档 根据传递的值,构建 ...
- C#操作XML学习之创建XML文件的同时新建根节点和子节点(多级子节点)
最近工作中遇到一个问题,要求创建一个XML文件,在创建的时候要初始化该XML文档,同时该文档打开后是XML形式,但是后缀名不是.在网上找了好些资料没找到,只能自己试着弄了一下,没想到成功了,把它记下来 ...
- dom4j创建xml
在前边介绍SAX,PULL等等既然能解析,当然也能生成.不过这里介绍dom4j创建xml文件,简单易懂. dom4j是独立的api,官网:http://www.dom4j.org/ 可以去这下载 ...
- Java读取、创建xml(通过dom方式)
创建一个接口 XmlInterface.java public interface XmlInterface { /** * 建立XML文档 * @ ...
- 创建XML
//创建XML XElement xelement = new XElement("request", new XElement("head", new XEl ...
- Java 创建xml文件和操作xml数据
java中的代码 import java.io.File; import java.io.StringWriter; import javax.xml.parsers.DocumentBuilder; ...
- TinyXML2读取和创建XML文件 分类: C/C++ 2015-03-14 13:29 94人阅读 评论(0) 收藏
TinyXML2是simple.small.efficient C++ XML文件解析库!方便易于使用,是对TinyXML的升级改写!源码见本人上传到CSDN的TinyXML2.rar资源:http: ...
- XML文件操作类--创建XML文件
这个类是在微软XML操作类库上进行的封装,只是为了更加简单使用,包括XML类创建节点的示例. using System; using System.Collections; using System. ...
- asp.net创建XML文件方法
方法一:按照XML的结构一步一步的构建XML文档. 通过.Net FrameWork SDK中的命名空间"System.Xml"中封装的各种类来实现的 方法一:按照XML的结 ...
随机推荐
- BZOJ 1857 传送带 (三分套三分)
在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxhgww想从 ...
- Caliburn.Micro学习笔记(四)----IHandle<T>实现多语言功能
Caliburn.Micro学习笔记目录 说一下IHandle<T>实现多语言功能 因为Caliburn.Micro是基于MvvM的UI与codebehind分离, binding可以是双 ...
- C#错过的10年
不知不觉,c#已经诞生n年了,人生有几个十年?c#就浪费了整整一个十年. 这十年里面,电脑发展缓慢,而服务端和手机发展迅速,这是一个移动和后端化的十年,而这个方向,正正是c#没有关注到的,c#把注意力 ...
- 当泛型方法推断,扩展方法遇到泛型类型in/out时。。。
说到泛型方法,这个是.net 2.0的时候引入的一个重要功能,c#2.0也对此作了非常好的支持,可以不需要显试的声明泛型类型,让编译器自动推断,例如: void F<T>(T value) ...
- CCPC2016沈阳站
A.模拟 B.模拟 C(hdu5950):(矩阵快速幂) 题意:求f(n)=2f(n-2)+f(n-1)+n^4 分析:矩阵快速幂,(f(n),f(n-1),n^4,n^3,n^2,n,1) 注意:矩 ...
- spring 整合 mongo
spring 非常强大,不仅在jdbc访问提供了jdbctemplate,而且在mongo访问上提供了mongoTemplate.闲话不多说,下边开始整合mongoTemplate. ONE: 添加s ...
- HttpResponse的使用方法
HttpResponse的使用方法: HttpRequest类是一个封闭HTTP提交信息的类型,而封闭HTTP输出信息的类型就是HttpResponse类,使用HttpResponse类可以实现三种类 ...
- sql语法:inner join on, left join on, right join on详细使用方法
inner join(等值连接) 只返回两个表中联结字段相等的行 left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有 ...
- ARCGIS9.3安装说明
1) 安装LMSetup.exe" 其中第一步选择第一项,并使用"37102011.efl9"文件做为lic文件,在使用之前需要将该文件中的主机名改为本机的机器名, ...
- Google map markers
现已被屏蔽 http://mabp.kiev.ua/2010/01/12/google-map-markers/ Надо по немногу отходить от празднывания но ...