문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top