Link to home
Start Free TrialLog in
Avatar of eddiewu80
eddiewu80

asked on

Need to read XML using ASP

I cannot for the life of me figure out how to read the resulting XML from the following code. I just need to extract the values from the XML so I can dump them into a database.

Any help would be greatly appreciated.

Thanks.
ipaddress = "67.70.91.145"
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","http://ipinfodb.com/ip_query.php?ip=" & ipaddress,false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send 
Response.ContentType = "text/xml"
response.write xmlhttp.responsexml.xml
Set xmlhttp = nothing

Open in new window

Avatar of hielo
hielo
Flag of Wallis and Futuna image

I tested what you posted and it works for me as is.
I suggest you try:
server.Createobject("MSXML2.ServerXMLHTTP.3.0")

OR
server.Createobject("MSXML2.ServerXMLHTTP.4.0")

IF the problem persists, try the attached code.
Function submitPost(url, data)
	Dim xmlhttp
	Set xmlhttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 
  
   xmlhttp.open "POST", url, false, "", "" 
   xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
   xmlhttp.setRequestHeader "Content-Length", Len(data)
   xmlhttp.send data '// send the xml to WP Pro and wait for a response
   
   submitPost = xmlhttp.responseText
End Function

Dim ipaddress
ipaddress = "67.70.91.145"

Response.ContentType = "text/xml"

Response.Write submitPost ("http://ipinfodb.com/ip_query.php", "ip=" & ipaddress)
Response.End

Open in new window

Avatar of eddiewu80
eddiewu80

ASKER

Thank you for the reply, but I'm not having trouble with the code I posted. The problem is that I do not know how to read the XML dump so that I can extract the individual node values.

If you could please provide with code showing how to do that, it would be great.
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much heilo! Fast and helpful response!!
Any time. Take care.