Response.GetResponseStream()转义双引号

时间:2009-10-14 22:47:39

标签: .net rss httpwebrequest httpwebresponse xmlreader

Response.GetResponseStream()返回带有转义字符的xml

<?xml version=\"1.0\" encoding=\"utf-8\"?>

因为这个XmlReader返回{None}。请帮忙吗?

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.Accept = "*/*"; req.Headers.Add("UA-CPU", "x86"); req.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; MS-RTC LM 8)"; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); XmlTextReader xRead = new XmlTextReader(resp.GetResponseStream());

如果我的呼叫来自客户端脚本Web服务调用,则

xRead为{None}。当我使用StreamReader检查响应流时

StreamReader reader = new StreamReader(resp.GetResponseStream() return reader.ReadToEnd()

我看到转义字符

<?xml version=\"1.0\" encoding=\"utf-8\"?>

1 个答案:

答案 0 :(得分:0)

如果没有关于如何实际获得响应的代码示例,我只需运行一个简单的String.Replace("\\"", "\"");。如果您的回复很大,它可能效率低下,但这是快速修复。