简体   繁体   中英

Integrate xml into Classic ASP

I need to send a GET request in XML format to: http://ip-api.com/xml

In order to get the following info:

    <?xml version="1.0" encoding="UTF-8"?>
<query>
<status>success</status>
<country><![CDATA[COUNTRY]]></country>
<countryCode><![CDATA[COUNTRY CODE]]></countryCode>
<region><![CDATA[REGION CODE]]></region>
<regionName><![CDATA[REGION NAME]]></regionName>
<city><![CDATA[CITY]]></city>
<zip><![CDATA[ZIP CODE]]></zip>
<lat><![CDATA[LATITUDE]]></lat>
<lon><![CDATA[LONGITUDE]]></lon>
<timezone><![CDATA[TIME ZONE]]></timezone>
<isp><![CDATA[ISP NAME]]></isp>
<org><![CDATA[ORGANIZATION NAME]]></org>
<as><![CDATA[AS NUMBER / NAME]]></as>
<query><![CDATA[IP ADDRESS USED FOR QUERY]]></query>
</query>

I know nothing about XML, only about Classic ASP.

Any idea how can I integrate this XML code in my ASP page?

Use the XMLDom to request and process the resulting XML.

Obviously think about catching any errors etc.

The code below just grabs the country - but should get you on your way

Set oXml = Server.CreateObject("Microsoft.XMLDOM")
with oXML
    .async = False
    .setProperty "ServerHTTPRequest", true
    .load("http://ip-api.com/xml")
    set result = .selectnodes("query")
    response.write "Country: " & result(0).selectSingleNode("country").text
End with

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM