【发布时间】:2016-10-26 07:55:01
【问题描述】:
我有一个 XML 文件,我将它附加到我的站点库中。 XML 有拉丁字符,所以我使用这种方法对其进行编码item.Attachments.Add("xyz.xml", Encoding.GetEncoding("iso-8859-1").GetBytes(writerXml.ToString()));
问题是当我尝试在浏览器中打开文件时,它会破坏出现特殊字符的位置。它给出了错误,因为无法使用 XSL 样式表查看 XML 输入。。
我想知道如何解决这个问题以及为什么我无法在浏览器中生成它?
尝试使用以下代码添加声明:
XDocument doc = new XDocument();
doc.Declaration = new XDeclaration("1.0","ISO-8859-1", null);
XElement element = new XElement("webapp", new XAttribute("name", webApp.Name), new XAttribute("id", webApp.Id),
MyInformation;
doc.Add(element);
return doc.ToString();
}
【问题讨论】:
-
请发布一个可重现的示例(XML +XSLT)。并说明您使用的是哪种浏览器。
-
使用 IE,我得到了文件中断的确切值(即特殊字符)。使用 Chrome,我收到行号和列号错误