Get Data From XML by Livecode -


i learn livecode , try few tutorials data xml format. confuse.

here xml code:

<current><city id="1642911" name="london"><coord lon="106.83" lat="-6.17"/><country>indonesia</country><sun rise="2014-05-29t22:56:30" set="2014-05-30t10:43:59"/></city><temperature value="302.254" min="302.254" max="302.254" unit="kelvin"/><humidity value="76" unit="%"/><pressure value="971.07" unit="hpa"/><wind><speed value="1.24" name="calm"/><direction value="20.5019" code="nne" name="north-northeast"/></wind><clouds value="20" name="few clouds"/><precipitation mode="no"/><weather number="801" value="few clouds" icon="02d"/><lastupdate value="2014-05-30t04:50:44"/></current> 

and here livecode code:

<?lc #get location put url ("http://api.openweathermap.org/data/2.5/weather?q=london&mode=xml") location  #get lon , lat put revcreatexmltree(location, false, true, false) locationtree put revxmlnodecontents(locationtree, "current/city/coord/lat") latitude put revxmlnodecontents(locationtree, "current/city/coord/lat") longitude   #put longitude , latitude information weather url put url ("http://api.openweathermap.org/data/2.5/weather?lat=" & latitude & "&lon=" & longitude & "&mode=html") weather  put weather 

the problem is, don't know how call data on xml (locationtree, "current/city/coord/lat") code <coord lon="106.83" lat="-6.17"/>. me? thank you.

i earth data when load

 http://api.openweathermap.org/data/2.5/weather?lat=0&lon=0&mode=html 

in browser.

could second put url command not right variables loaded , loads latitude , longitude = 0?

also, make sure have right structure revxmlnodecontents:

put revxmlnodecontents(ptree, "preferences/recentdocuments/" & trecentdocument) & return after tlistofrecentdocuments 

your example looks not know city load long , lat. can see doing proper thing when stepping trough code?

update: 1. correct typo locationtree on put revcreatexmltree


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -