2017-04-04 38 views
0

私は、ユーザがアクセスしようとしている国の名前を表示するために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> 

答えて

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

のようなものを読む必要があり、これは完璧な男はどうもありがとうございまし作品! – muratkh