Hi All,
I am getting error while am loading RSS Stream in XMLDocument object. The error is as follows.
"System.Xml.XmlException: '', hexadecimal value 0x19, is an invalid character. Line 18, position 32."
I understand that this is becasue I have one apostrophe in the RSS Feed.
I have tried few tricks to get rid of apostrophe but of no use.
Tried the below trick
1. //CONVERTING STREAM TO STRING
StreamReader reader = new StreamReader(rssStream);
2. //Removing ' from the string
without = fortest.Replace("'", "\"");
3. //CONVERTING STRING TO STREAM
byte[] byteArray = Encoding.ASCII.GetBytes(without);
MemoryStream stream = new MemoryStream( byteArray );
4. XmlTextReader reader1 = new XmlTextReader(stream);
5. rssDoc.Load(reader1);
Below is the code wrriten.....
#############################
-
System.Net.WebRequest myRequest = System.Net.WebRequest.Create(rssURL);
-
System.Net.WebResponse myResponse = myRequest.GetResponse();
-
-
System.IO.Stream rssStream = myResponse.GetResponseStream();
-
System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument();
-
-
//CONVERTING A STREAM TO STRING
-
StreamReader reader = new StreamReader(rssStream);
-
fortest = reader.ReadToEnd();
-
-
//Removing ' from the string
-
without = fortest.Replace("'", "\"");
-
-
-
//CONVERTING A STRING TO STREAM
-
byte[] byteArray = Encoding.ASCII.GetBytes(without);
-
MemoryStream stream = new MemoryStream( byteArray );
-
-
XmlTextReader reader1 = new XmlTextReader(stream);
-
-
-
try
-
{
-
rssDoc.Load(reader1);
-
}
-
catch (System.Xml.XmlException xe)
-
{
-
}
-
But its of no use, let me know if you have any idea about it. its lil urgetn
Thanks,
Manik