Problem Reading XML from Website

S

Scott McNair

Hi,

I'm trying to read a bit of XML from the following site:

http://www.wowarmory.com/character-sheet.xml?r=Bladefist&n=Coquette

The xml document relies heavily on xsl... however if you view the source of
the page you'll see that it is indeed raw xml that's being served.

I'm using the following code to pull the xml document in string format:

Public Shared Function GetPageAsString(ByVal address As Uri) As String
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim result As String

Try
request = DirectCast(WebRequest.Create(address), HttpWebRequest)
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
result = reader.ReadToEnd()
Finally
If Not response Is Nothing Then response.Close()
End Try
Return result
End Function

However when I view the resulting string value, it shows the xsl-parsed
code. How can I retrieve just the raw xml?

Regards,
Scott M.
 
M

Martin Honnen

Scott said:
I'm trying to read a bit of XML from the following site:

http://www.wowarmory.com/character-sheet.xml?r=Bladefist&n=Coquette

The xml document relies heavily on xsl... however if you view the source of
the page you'll see that it is indeed raw xml that's being served.

I'm using the following code to pull the xml document in string format:

Public Shared Function GetPageAsString(ByVal address As Uri) As String
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim result As String

Try
request = DirectCast(WebRequest.Create(address), HttpWebRequest)

request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
result = reader.ReadToEnd()
Finally
If Not response Is Nothing Then response.Close()
End Try
Return result
End Function

However when I view the resulting string value, it shows the xsl-parsed
code. How can I retrieve just the raw xml?

Your code simply makes a HTTP GET request and reads the response. If you
get HTML then the server sends HTML. It seems to help to set the HTTP
UserAgent as shown above, then I get XML and not HTML.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top