在xmldocument中插入<?xml version="1.0" encoding="GB2312"?> 先保存xml文件,用文本方式打开,添加 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 frankly, Oceanson's method is not so badusing System;using System.Xml;class TestXml{ public static void Main() { String sFile = "a.xml"; XmlDocument doc = new XmlDocument(); doc.Load(sFile); XmlProcessingInstruction newPI; String PItext = "type='text/xsl' href='book.xsl'"; newPI = doc.CreateProcessingInstruction("xml-stylesheet", PItext); doc.InsertBefore(newPI, doc.FirstChild); XmlTextWriter xtw = new XmlTextWriter(sFile, System.Text.Encoding.GetEncoding("GB2312")); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); doc.Save(xtw); xtw.WriteEndDocument(); xtw.Close(); }} 一个JS的返回值问题! 各位大神,求一款编辑器 treeview 分层加载 System.Web.UI.Page.RegisterStartupScript已过时 开源博客 [咨询]学习asp.net,数据库需要掌握到什么程度?? 一个关于139邮箱那种框架 请问如何修改两个有关系的表?谢谢 关于在js中获得当前url信息的问题 如何连ACCESS库????? 怎样在SQL SERVER 2000中建立一张表,这张表的主键是自动增加的。? 重分请教难题!1020分,说到做到
using System.Xml;class TestXml
{
public static void Main()
{
String sFile = "a.xml";
XmlDocument doc = new XmlDocument();
doc.Load(sFile);
XmlProcessingInstruction newPI;
String PItext = "type='text/xsl' href='book.xsl'";
newPI = doc.CreateProcessingInstruction("xml-stylesheet", PItext);
doc.InsertBefore(newPI, doc.FirstChild); XmlTextWriter xtw = new XmlTextWriter(sFile, System.Text.Encoding.GetEncoding("GB2312"));
xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
doc.Save(xtw);
xtw.WriteEndDocument();
xtw.Close();
}
}