Wayne,

First, you should uncheck the Detailed Response option, it's not necessary.

It's causing you to have an XML document inside of another XML document, which 
complicates processing.

Once you do that, @DOM the result.

The colons separate the namespace from the node name. You can use "*:" to mean 
"any namespace". This is usually required because TS doesn't have full 
namespace support.

This tag: <@ELEMENTVALUE dom xpath='//*:countryName'>

Should return the name of the country (untested).

You can read that xpath as:

// = anywhere in the document
*: = any namespace in the document
countryName = an element named 'countryName'

Note that if there were more than one countryName node, you might have to use a 
more specific xpath.

Robert



-----Original Message-----
From: Wayne Irvine [mailto:wa...@byteserve.com.au]
Sent: Tuesday, March 11, 2014 12:10 AM
To: TeraScript-Talk@terascript.com
Subject: TeraScript-Talk: Trying to work out what country I'm in.

Another XML question.

I'm writing a small taf to determine the country of origin of the browser by IP 
address.

I'm using the hostip.info API.

http://bigreviewtv.byteserve.com.au/ipcountry.taf

This returns httpData:

<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE DETAILED_RESPONSE_SYSTEM 
> <HTTP_RESPONSE Version="0x02000002">
        <STATUS>
                <CODE>200</CODE>
                <TEXT>OK</TEXT>
        </STATUS>
        <HEADER NAME="Date"><![CDATA[Tue, 11 Mar 2014 04:08:31 GMT]]></HEADER>
        <HEADER NAME="Server"><![CDATA[LiteSpeed]]></HEADER>
        <HEADER NAME="Connection"><![CDATA[close]]></HEADER>
        <HEADER NAME="X-Powered-By"><![CDATA[PHP/5.4.16]]></HEADER>
        <HEADER NAME="Content-Type"><![CDATA[text/xml; 
charset=iso-8859-1]]></HEADER>
        <HEADER NAME="Expires"><![CDATA[Wed, 12 Mar 2014 04:08:31 
GMT]]></HEADER>
        <HEADER NAME="Last-Modified"><![CDATA[Thu, 01 Jan 1970 00:00:00 
GMT]]></HEADER>
        <HEADER NAME="Cache-Control"><![CDATA[public, max-age=86400]]></HEADER>
        <HEADER NAME="Pragma"><![CDATA[!invalid]]></HEADER>
        <HEADER NAME="Access-Control-Allow-Origin"><![CDATA[*]]></HEADER>
        <HEADER NAME="Content-Length"><![CDATA[921]]></HEADER>
        <HEADER NAME="Vary"><![CDATA[User-Agent]]></HEADER>
        <BODY><![CDATA[<?xml version="1.0" encoding="ISO-8859-1" ?> 
<HostipLookupResultSet version="1.0.1" xmlns:gml="http://www.opengis.net/gml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:noNamespaceSchemaLocation="http://www.hostip.info/api/hostip-1.0.1.xsd";>
 <gml:description>This is the Hostip Lookup Service</gml:description>  
<gml:name>hostip</gml:name>  <gml:boundedBy>
  <gml:Null>inapplicable</gml:Null>
 </gml:boundedBy>
 <gml:featureMember>
  <Hostip>
   <ip>203.24.144.202</ip>
   <gml:name>Sydney</gml:name>
   <countryName>AUSTRALIA</countryName>
   <countryAbbrev>AU</countryAbbrev>
   <!-- Co-ordinates are available as lng,lat -->
   <ipLocation>
    <gml:pointProperty>
     <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326";>
      <gml:coordinates>151,-34</gml:coordinates>
     </gml:Point>
    </gml:pointProperty>
   </ipLocation>
  </Hostip>
 </gml:featureMember>
</HostipLookupResultSet>
]]></BODY>
</HTTP_RESPONSE>

I am stuck defining the @ELEMENTVALUE string to pull out the value of country. 
I think the colons on gml data is messing things up.

Wayne Irvine
w: http://www.byteserve.com.au/
p: +61 2 9960 6099
m: 0409 960 609




----------------------------------------

To unsubscribe from this list, please send an email to lists...@terascript.com 
with "unsubscribe terascript-talk" in the body.




----------------------------------------

To unsubscribe from this list, please send an email to lists...@terascript.com 
with "unsubscribe terascript-talk" in the body.

Reply via email to