加载 xml 文档失败,带有特殊字符 » [英] loading xml document fails with special character »
本文介绍了加载 xml 文档失败,带有特殊字符 »的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个 RSS 提要并且该文档包含一个特殊字符 »
I'm consuming an RSS feed and the document contains a special character »
我猜提要的编码不正确,但我无法更改.我想覆盖它或只是用友好的东西替换有问题的字符.
I'm guessing the feed is not encoded properly but I can't change that. I'd like to override that or just replace the offending char with something friendly.
using (Stream stream = response.GetResponseStream())
{
using (XmlReader reader = XmlReader.Create(stream))
{
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(reader); //<--- FAILS HERE
//parse the items of the feed
...
推荐答案
»
是一个 HTML 命名实体,在 XML 中不受支持.开箱即用,XML 仅支持&
、'
、"
、>
和 <
.
»
is an HTML named entity and is not supported in XML. Out of the box, XML only supports &
, '
, "
, >
and <
.
改用相应的数字实体»
(或十六进制»
).
Use the corresponding numeric entity »
(or hexadecimal »
) instead.
这篇关于加载 xml 文档失败,带有特殊字符 &raquo;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文