Question

I'm attempting to parse the xml located at view-source:http://www.parkrun.com.au/wp-content/themes/parkrun/xml/geo.xml. This is my first attempt at doing this type of thing so my knowledge is limited. I've parsed plenty of websites but not xml.

I've attempted the following code but keep getting an error:

Dim xdoc As New XmlDocument
xdoc.LoadXml("http://www.parkrun.com.au/wp-content/themes/parkrun/xml/geo.xml")

Error: {"Data at the root level is invalid. Line 1, position 1."}

What I'm attempting to do is parse the xml and then loop through the records to build an array based on each location and state (eg from below it would be ipswichqld, Queensland). For example below ipswichqld belongs to Queensland (r="4" joins with id="4").

Any help on this would be really appreciated, thanks in advance.

Was it helpful?

Solution

Instead of LoadXml() method, you should've used XmlDocument.Load() method to load XML from local or online source file :

Dim xdoc As New XmlDocument
xdoc.Load("http://www.parkrun.com.au/wp-content/themes/parkrun/xml/geo.xml")

Unfortunately, particular website you're trying to load XML from doesn't allow this operation (not even if you open that XML URL from browser). I got this exception when trying above code :

WebException

The remote server returned an error: (403) Forbidden.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top