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

eddiewu80Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
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

0
eddiewu80Author Commented:
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.
0
hieloCommented:

<%
Dim ipaddress
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

'method 1:
Set nodeList = xmlhttp.responsexml.documentElement.selectNodes("*")
For Each node in nodeList
	Response.Write "<br>" & node.nodeName & ": " & node.text
Next

Response.Write "<hr>"
'method 2
For i=0 To xmlhttp.responsexml.documentElement.childnodes.length-1
	Response.Write "<br>" & xmlhttp.responsexml.documentElement.childnodes(i).nodeName & ": "& xmlhttp.responsexml.documentElement.childnodes(i).text
Next
Set xmlhttp = nothing
%>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eddiewu80Author Commented:
Thank you so much heilo! Fast and helpful response!!
0
hieloCommented:
Any time. Take care.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.