日期:2014-05-18  浏览次数:20515 次

一个小问题,大家帮看下。谢谢
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