XML求助(在线等)

parol2910 2004-10-25 08:12:21
<?xml version="1.0" encoding="GB2312"?>
<document></document>

我怎么用XmlDocument中的方法在<?xml version="1.0" encoding="GB2312"?>下边添上
<?xml:stylesheet type='text/xsl' href='../dotnet.xsl'?>
...全文
84 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sjzwinfor 2004-10-25
  • 打赏
  • 举报
回复
XmlTextWriter xw=new XmlTextWriter(dir,null);
xw.WriteStartDocument();
// 写入处理指令
string process ="type='text/xsl'"+" href="+"'moban001.xsl'";
xw.WriteProcessingInstruction("xml-stylesheet",process);

明白了吧
parol2910 2004-10-25
  • 打赏
  • 举报
回复
xw是什么?
sjzwinfor 2004-10-25
  • 打赏
  • 举报
回复
上面的xw是XmlTextWriter的一个实例
XmlTextWriter xw=new XmlTextWriter(dir,null);
孟子E章 2004-10-25
  • 打赏
  • 举报
回复
string xml = "<?xml version=\"1.0\" encoding=\"gb2312\"?><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.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));
sjzwinfor 2004-10-25
  • 打赏
  • 举报
回复
string process ="type='text/xsl'"+" href="+"'moban001.xsl'";
xw.WriteProcessingInstruction("xml-stylesheet",process);
孟子E章 2004-10-25
  • 打赏
  • 举报
回复
souso

110,549

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧