narko 0 Newbie Poster

These days I’ve been working on creating feed reader which retrieves data from weather.com site. They provide detailed SDK and information you’ll need to read information from their site.

I had to use ASP as script language to read XOAP service data. What is interesting a lot of sites provide good information how to read XML from ASP. And all they say the following code should work:

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.setProperty "ServerHTTPRequest", true
objXML.Load (xmlURL)
If objXML.parseError.errorCode <> 0 Then
Response.Write objXML.parseError.reason
End If

where xmlURL is path to actual XML resource (in case of weather.com it’s xoap.weather.com/weather/… ). But it did not. When I put there local path to XML file on my local drive - it worked perfectly but when I used remote URL - it said kinda “Empty XML resource”. I spent some time investigating this issue and it turned out that I had to use extra parameter in order to get access to remote URL (as far as I understood from the explanation this problem appears due to older XMLDOM versions and probably it won’t ever happen on newer Windows installation). So final working code looks like this:

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.setProperty "ServerHTTPRequest", true
objXML.Load (xmlURL)
If objXML.parseError.errorCode <> 0 Then
Response.Write objXML.parseError.reason
End If

I hope that was helpfull

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.