经典的ASP如何读取XML数据

经典的ASP如何读取XML数据

问题描述:

我试图使用IP API来显示国家的名称,用户试图访问。我可以很好地解析xml,但是我不能选择国家的名称标签并显示它。任何帮助将被真正赞赏。经典的ASP如何读取XML数据

<% 

Dim URL, objXML, value 
URL = "http://ip-api.com/xml/ipaddress" 
Set objXML = Server.CreateObject("MSXML2.DOMDocument.6.0") 
objXML.setProperty "ServerHTTPRequest", True 
objXML.async = False 
objXML.Load URL 

Response.Write objXML.parseError.reason 

value = objXML.documentElement.Text 

set objXML = nothing 

%> 

<%= value %> 

此代码将xml转换为文本。相反,我想只使用国家标签和response.write该信息。

XML数据应该读这样的事情

<query> 
<status> 
data here 
</status> 
<country> 
data here 
</country> 
<countryCode> 
data here 
</countryCode> 
<region> 
data here 
</region> 
<regionName> 
data here 
</regionName> 
<city> 
data here 
</city> 
<zip> 
data here 
</zip> 
<lat> 
data here 
</lat> 
<lon> 
data here 
</lon> 
<timezone> 
data here 
</timezone> 
<isp> 
data here 
</isp> 
<org> 
data here 
</org> 
<as> 
data here 
</as> 
<query> 
data here 
</query> 
</query> 

<% 
value = objXML.selectSingleNode("//query/country").text 
Response.Write value 
%> 
+0

这个作品完美的人非常感谢你! – muratkh