XMLDocument,读取Node的问题

时间:2010-09-23 13:38:48

标签: c# .net xml webrequest

我正在做以下事情:

    System.Net.WebRequest myRequest = System.Net.WebRequest.Create("http://www.atlantawithkid.com/feed/");
System.Net.WebResponse myResponse = myRequest.GetResponse();

System.IO.Stream rssStream = myResponse.GetResponseStream();
System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument();
rssDoc.Load(rssStream);

System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");
System.Xml.XmlNode rssDetail;

// FEED DESCRIPTION

string sRssDescription; 
rssDetail = rssItems.Item(0).SelectSingleNode("description");
if (rssDetail != null)
    sRssDescription = rssDetail.InnerText;

但是,当我阅读“description”节点并查看InnerText或InnerXML时,该字符串与原始XML文档中的字符串不同。

字符串返回有和省略号,数据被截断。但是,在原始XML文档中,我可以看到数据。

有没有办法在不更改数据的情况下选择此节点?

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

我怀疑你正在查看调试器中的字符串,这可能会截断数据。 (或者你将其写入截断文本的其他内容。)

我非常怀疑这是一个XmlDocument问题。

我建议您记录 InnerText某个地方,您知道您将能够获得完整的数据,因此您可以确定。