scm0sml
asked on
'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.
I'm getting the following error when loading an xml doc which is an rss feed:
'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.
I presume they have included a space at the front of the xml have they?
Obviously I can't change that as am just using the feed, this is how I load it:
Dim xmlDoc As New XmlDocument
xmlDoc.Load("http://www.bournemouthecho.co.uk/news/rss/")
Is there anything I can do to that to work around the problem?
'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.
I presume they have included a space at the front of the xml have they?
Obviously I can't change that as am just using the feed, this is how I load it:
Dim xmlDoc As New XmlDocument
xmlDoc.Load("http://www.bournemouthecho.co.uk/news/rss/")
Is there anything I can do to that to work around the problem?
ASKER
Right I needed it in vb.net so used a convertor and got:
Dim webReq As HttpWebRequest = DirectCast(WebRequest.Crea te("http://www.bournemouthecho.co.uk/news/rss/"), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(webReq.GetRespo nse(), HttpWebResponse)
Dim xml As String = String.Empty
Using sr As New StreamReader(response.GetR esponseStr eam())
xml = sr.ReadToEnd()
End Using
xml = xml.Replace(Convert.ToStri ng(CByte(& H1F)), String.Empty)
should this line:
xml = xml.Replace(Convert.ToStri ng(CByte(& H1F)), String.Empty)
be using &H1F??
When I try:
xml = xml.Replace(Convert.ToStri ng(CByte(" 0x1F")), String.Empty)
I get:
xml = xml.Replace(Convert.ToStri ng(CByte(" 0x1F")), String.Empty)
Any ideas?
Dim webReq As HttpWebRequest = DirectCast(WebRequest.Crea
Dim response As HttpWebResponse = DirectCast(webReq.GetRespo
Dim xml As String = String.Empty
Using sr As New StreamReader(response.GetR
xml = sr.ReadToEnd()
End Using
xml = xml.Replace(Convert.ToStri
should this line:
xml = xml.Replace(Convert.ToStri
be using &H1F??
When I try:
xml = xml.Replace(Convert.ToStri
I get:
xml = xml.Replace(Convert.ToStri
Any ideas?
OK, you lost me (or I'm completely blind)....
What's the difference between these two?
xml = xml.Replace(Convert.ToStri ng(CByte(" 0x1F")), String.Empty)
xml = xml.Replace(Convert.ToStri ng(CByte(" 0x1F")), String.Empty)
What's the difference between these two?
xml = xml.Replace(Convert.ToStri
xml = xml.Replace(Convert.ToStri
ASKER
Sorry, I meant to say I get:
Conversion from string "0x1F" to type 'Byte' is not valid.
I'm an idiot!
Conversion from string "0x1F" to type 'Byte' is not valid.
I'm an idiot!
OK... I'm following now. In VB, the byte literal is done with &H. So in your example, it would be:
xml = xml.Replace(Convert.ToStri ng(CByte(& H1F)), String.Empty)
xml = xml.Replace(Convert.ToStri
ASKER
I'm now getting:
Illegal characters in path.
Something weird going on, when I debug the xml it is:¿
????
Illegal characters in path.
Something weird going on, when I debug the xml it is:¿
????
Can you post a small chunk of the XML file you're dealing with?
ASKER
I tried to debug the xml to see what I was getting, it came out with what was in my last post?!
Seems the replace has messed this up?
The feed I'm getting the original xml from is:
http://www.bournemouthecho.co.uk/news/rss/
Seems the replace has messed this up?
The feed I'm getting the original xml from is:
http://www.bournemouthecho.co.uk/news/rss/
I already tried that.. after it gets rendered by my browser, and I do a "view source", it looks clean as a whistle.
<?xml version="1.0"?>
<?xml-stylesheet......
That's why I suggested that you capture the incomming RSS feed via code, save it to disk, and the post the results here for us to see.
<?xml version="1.0"?>
<?xml-stylesheet......
That's why I suggested that you capture the incomming RSS feed via code, save it to disk, and the post the results here for us to see.
ASKER
apologies for not finishing this post off, the issue is still there for me.
can you put this simple code into a test page?
Dim webReq As HttpWebRequest = DirectCast(WebRequest.Crea te("http://www.bournemouthecho.co.uk/news/rss/"), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(webReq.GetRespo nse(), HttpWebResponse)
Dim xml As String = String.Empty
Using sr As New StreamReader(response.GetR esponseStr eam())
xml = sr.ReadToEnd()
End Using
Straight away there is something wrong with the string xml....
Any ideas?
can you put this simple code into a test page?
Dim webReq As HttpWebRequest = DirectCast(WebRequest.Crea
Dim response As HttpWebResponse = DirectCast(webReq.GetRespo
Dim xml As String = String.Empty
Using sr As New StreamReader(response.GetR
xml = sr.ReadToEnd()
End Using
Straight away there is something wrong with the string xml....
Any ideas?
ASKER
That example is c#.
I have converted to vb.net but still not working.
Below is a simple piece of code that could go on a test page for someone to easily replicate the problem....
I have converted to vb.net but still not working.
Below is a simple piece of code that could go on a test page for someone to easily replicate the problem....
Dim webReq As HttpWebRequest = DirectCast(WebRequest.Create("http://www.bournemouthecho.co.uk/news/rss/"), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(webReq.GetResponse(), HttpWebResponse)
Dim xml As String = String.Empty
Using sr As New StreamReader(response.GetResponseStream())
xml = sr.ReadToEnd()
End Using
ASKER
The input is coming in compressed. To uncompress, add this line before getting the response:
webReq.AutomaticDecompress ion = DecompressionMethods.GZip
This is using your test case. Displaying the xml variable was what clued me in to the issue.
See: http://stackoverflow.com/questions/2973208/automatically-decompress-gzip-response-via-webclient-downloaddata
Gary Davis
webReq.AutomaticDecompress
This is using your test case. Displaying the xml variable was what clued me in to the issue.
See: http://stackoverflow.com/questions/2973208/automatically-decompress-gzip-response-via-webclient-downloaddata
Gary Davis
ASKER
im getting:
Illegal characters in path now?
Illegal characters in path now?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
did you try a replace workaround?
have a look here
http://forums.asp.net/t/1120421.aspx