xml中有不常见字符,XmlDocument.load时就出错了
询问有什么解决方法吗?xml:
<?xml version="1.0" encoding="GB2312" ?>
- <rss version="2.0">
- <channel>
<title>网络实时快照</title>
- <item>
<title>上海浦东陆家嘴</title>
<link>http://www.ds-shanghai.org.cn/webcam/image.jpg</link>
<author>mztk</author>
<pubDate>实时更新</pubDate>
<description />
</item>
</channel>
</rss>
询问有什么解决方法吗?xml:
<?xml version="1.0" encoding="GB2312" ?>
- <rss version="2.0">
- <channel>
<title>网络实时快照</title>
- <item>
<title>上海浦东陆家嘴</title>
<link>http://www.ds-shanghai.org.cn/webcam/image.jpg</link>
<author>mztk</author>
<pubDate>实时更新</pubDate>
<description />
</item>
</channel>
</rss>
上面的xml格式是没有错误的,请确定你保存的时候的编码方式,如果是UTF-8的话,请换成ANSI试试。
我把这个xml例子放在朋友的服务器上了,http://www.fxdm.net/images/rss.xml:)
StreamReader reader1 = new StreamReader(loadloadfile);
document1.Load(reader1);
reader1.DiscardBufferedData();
reader1.Close();
报:
exception1.Message "“”(十六进制值 0x0E)是无效的字符。 行 3,位置 11。"
StreamReader reader1 = new StreamReader(loadloadfile, Encoding.GetEncoding("gb2312"));
有时候没有用,由时候其他的中文就变成乱码了.这个xml是我从众多错误的字符里面挑出来的,自己写的方便测试的,如果要改的话,可以有方法让程序自己改吗,
xml 不是我人为操作的