XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>");
XmlDeclaration xmldecl;
xmldecl = doc.CreateXmlDeclaration("1.0","UTF-8",null);
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmldecl, root);
doc.Save("c:\\xx.xml");
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>");
XmlDeclaration xmldecl;
xmldecl = doc.CreateXmlDeclaration("1.0","UTF-8",null);
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmldecl, root);
doc.Save("c:\\xx.xml");
解决方案 »
- 真正用过强类型的帮我看下,,,,在线等,,,着急
- 模拟登陆人人网 参考他们的教程遇到问题 求高手指点
- 做一个能够以文件夹为单位提取txt内容的winform,求助!
- 关于 手机收费的 软件编写提问。
- 如何得知一个进程打开了哪些文件?
- 我用C#做的中文系统,要放到日文服务器上运行,有乱码
- DataSet.Merge(ds1)之后,如何将更新写入数据库?
- 安装和部署项目是发生的错误
- 如何让.Net(c#语言)能调用RPC/Literal类型的Web Service
- C#生成的DLL怎么在VC或VB中调用
- 请问在C#内如何调用可执行程序,如同VC里的Winexec函数,C#里面有没有这样的方法
- 对正则表达式很不明白,请进来解释一下好吧
string xml = "<Text><Textxml> <Name> 知道天高地厚</Name></Textxml></Text> ";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(xml);
Response.Clear();
Response.Write (Server.HtmlEncode(doc.OuterXml));
Response.Write ("<hr>");
System.Xml.XmlDeclaration xmldecl;
xmldecl = doc.CreateXmlDeclaration("1.0","UTF-8",null);
doc.InsertBefore(xmldecl, doc.DocumentElement);
System.Xml.XmlProcessingInstruction newPI;
String PItext = "type='text/xsl' href='Text.xsl'";
newPI = doc.CreateProcessingInstruction("xml-stylesheet", PItext);
doc.InsertBefore(newPI,doc.DocumentElement);
System.Xml.XmlNode nod = doc.SelectSingleNode("//Textxml");
System.Xml.XmlNode newNode = doc.CreateNode(System.Xml.XmlNodeType.Element,"Content","");
System.Xml.XmlCDataSection CData;
CData = doc.CreateCDataSection(" 真是不知高地厚 的东西我的心情好 ");
newNode.AppendChild(CData);
nod.AppendChild(newNode);
Response.Write (Server.HtmlEncode(doc.OuterXml));
doc.Save(Server.MapPath("ok.xml"));