当前位置: 代码迷 >> ASP.NET >> 一个小疑点,大家帮看下。多谢
  详细解决方案

一个小疑点,大家帮看下。多谢

热度:2850   发布时间:2013-02-25 00:00:00.0
一个小问题,大家帮看下。谢谢
myds.WriteXml(Server.MapPath( "address.xml "));  
每次重写一个xml的时候:
它的xml头是:   <?xml   version= "1.0 "   standalone= "yes "?>
而我希望它出来是这样: <?xml   version= "1.0 "   encoding= "utf-8 "   standalone= "yes "?>
请问怎么弄?大家指教.

------解决方案--------------------------------------------------------
ds.GetXml();得到xml 再修改
------解决方案--------------------------------------------------------
有高手在,友情帮顶!
------解决方案--------------------------------------------------------
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath( "address.xml "));
XmlDeclaration dec = doc.FirstChild;
dec.Encoding = "utf-8 ";
doc.Save(Server.MapPath( "address.xml "));

------解决方案--------------------------------------------------------
try ->

System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(Server.MapPath( "address.xml "));

writer.Setting.Encoding = System.Text.Encoding.UTF8

myds.WriteXml(writer);

------解决方案--------------------------------------------------------
up
  相关解决方案