views:

266

answers:

2

Response.GetResponseStream() is returning xml with escape characters

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

Because of this XmlReader return {None}. Help please?

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());

xRead is {None} if I the call is from client Script Web Service call. When I check the response stream using a StreamReader

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

I see the escape characters

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

A: 

Without a code sample of how you actually get the response, I would just run a simple String.Replace("\\"", "\"");. It could get inefficient if your responses are large, but that's the quick fix.

nasufara
you're right that it's the "quick fix", but this sort of bludgeoning-the-values-to-fit-what-you-want-them-to-be-instead-of-figuring-out-why-they're-wrong attitude will get you into a _lot_ of trouble down the road. You should always try to find the source of your bugs rather than just hide them, because they will always come back to bite you if they aren't fixed properly.
rmeador
This is without a code sample, without actually knowing whats going on, this is the best I can offer with the information he's given me :/ I will update the answer if more information is provided.
nasufara
A: 

Thanks for your replies. I have edited my original query with the code

Clark
You should modify your original question, not post it in an answer.
nasufara