ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XML Parsing Problem

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming
View previous topic :: View next topic  
Author Message
Jimbalaya



Joined: 24 Feb 2006
Posts: 6
Location: Frisco, TX, USA

PostPosted: Fri Feb 24, 2006 12:54 pm    Post subject: XML Parsing Problem Reply with quote

Hi,

I'm having trouble with parsing an XML file from Yahoo's Geocoder.

I'm getting an (0x800A01A8) Object required error on the line following line: Response.Write "Latitude" & xmlDoc.selectSingleNode("Latitude").Text

If I coment that our I get the same error on the next line.

Here is my code and the xml file I should be returning follows.

Code:
<%
                       
xmlURL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=SmartStart&street=3821%20Plantation%20Ln%20&zip=75035"
                       
'// Create the XMLHTTP object
Set xmlHTTP = Server.CreateObject("MSXML2.XMLHTTP")
                       
'// Fire off the request!
xmlHTTP.Open "GET", xmlURL
xmlHTTP.Send

'// Load the XML parser
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.loadXML (xmlHTTP.ResponseXML.xml)
                           
'// Set the Result node
Set arrResult = xmlDoc.selectSingleNode("//ResultSet/Result")
                           
'// Show Latitude and Longitude
Response.Write "Latitude" & arrResult.selectSingleNode("Latitude").Text
Response.Write "Longitude" & ArrResult.selectSingleNode("Longitude").Text
                           
'// Unload XML parser
Set xmlDoc = Nothing

'// Destroy the object
Set xmlHTTP = Nothing

%>

Yahoo XML
Code:

<?xml version="1.0" encoding="UTF-8" ?>
- <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">
- <Result precision="address">
  <Latitude>33.109863</Latitude>
  <Longitude>-96.781642</Longitude>
  <Address>3821 PLANTATION LN</Address>
  <City>FRISCO</City>
  <State>TX</State>
  <Zip>75035-8587</Zip>
  <Country>US</Country>
  </Result>
  </ResultSet>
- <!--  ws01.search.re2.yahoo.com compressed/chunked Fri Feb 24 06:41:55 PST 2006 -->


Thank you,
Jim
Back to top
View user's profile Send private message Visit poster's website
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Fri Feb 24, 2006 1:21 pm    Post subject: Reply with quote

Most likely the returned XML does not have node "Latitude". make sure that the XML Yahoo returns doesn't have errors.



Paul
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Jimbalaya



Joined: 24 Feb 2006
Posts: 6
Location: Frisco, TX, USA

PostPosted: Fri Feb 24, 2006 1:25 pm    Post subject: Reply with quote

Update:

I found out that the xmlHTTP.ReadyState never makes it past 1 (loading). Does anyone know why this might be?
Back to top
View user's profile Send private message Visit poster's website
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Fri Feb 24, 2006 2:08 pm    Post subject: Reply with quote

Can you access the http://api.local.yahoo.com/MapsService/V1/geocode?appid=SmartStart&street=3821%20Plantation%20Ln%20&zip=75035 URL directly from your browser? Does it return what it should?




Paul
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Jimbalaya



Joined: 24 Feb 2006
Posts: 6
Location: Frisco, TX, USA

PostPosted: Fri Feb 24, 2006 2:47 pm    Post subject: Reply with quote

paul wrote:
Can you access the http://api.local.yahoo.com/MapsService/V1/geocode?appid=SmartStart&street=3821%20Plantation%20Ln%20&zip=75035 URL directly from your browser? Does it return what it should?




Paul


Yes, the xml file returns just as it should.
Back to top
View user's profile Send private message Visit poster's website
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Fri Feb 24, 2006 4:02 pm    Post subject: Reply with quote

At what point do you check the xmlHTTP.ReadyState value?




Paul
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Jimbalaya



Joined: 24 Feb 2006
Posts: 6
Location: Frisco, TX, USA

PostPosted: Fri Feb 24, 2006 4:12 pm    Post subject: Reply with quote

paul wrote:
At what point do you check the xmlHTTP.ReadyState value?




Paul


Right after the xmlHTTP.Send call.

I also tried the following loop:

do while xmlHTTP.ReadyState = 1
...
loop

But it just kept looping until I stopped the browser.
Back to top
View user's profile Send private message Visit poster's website
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Fri Feb 24, 2006 8:13 pm    Post subject: Reply with quote

Hi Jim,

I've solved your problem Smile

Simply change the following line:

xmlHTTP.Open "GET", xmlURL

to the following:

xmlHTTP.Open "GET", xmlURL, False

Let me know if it works for you?




Peter
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Jimbalaya



Joined: 24 Feb 2006
Posts: 6
Location: Frisco, TX, USA

PostPosted: Fri Feb 24, 2006 11:45 pm    Post subject: Reply with quote

Hey Paul,

Well, I'm not sure if this is progress but it's different.

Now I'm getting:

msxml3.dll (0x800C0005)
The system cannot locate the resource specified.

on the xmlHTTP.Send statement.

Any Ideas as to what that means.

Thanks for all the help,

Jim
Back to top
View user's profile Send private message Visit poster's website
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Sat Feb 25, 2006 12:45 am    Post subject: Reply with quote

Strange, it works on my local machine. Here is what I found, which might help you:

http://p2p.wrox.com/topic.asp?TOPIC_ID=9172

Let me know if you find a solution.




Paul
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial