I am getting xml data through an httpwebrequest. The following code was working fine. But something changed and suddenly started to give me an exception on Read() method with error : The '', Hexadecimal value 0x1F, is not a valid character. Line 1, Item 1. In web browser sURL gives me a valid xml. I dont know what changed.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sURL);
req.Method = "GET";
WebResponse response = req.GetResponse();
StreamReader resStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
XmlTextReader reader = new XmlTextReader(resStreamReader);
while (reader.Read())
{
// some code
}
At This MSDN Topic Same problem discussed, and result is that,
And this stackoverflow topic solves the problem
0x1F XML Error Solution
You should check the response from your url about possible GZip compression usages.
Have a nice day.