Peter forgot to add some code snippets. This from my Google geo-coding xml
parsing routine.
***********
put url ("http://maps.googleapis.com/maps/api/geocode/xml?address=" & add1
& comma & "+" & CSZ & "&sensor=false") into gxml
delete line 1 in gxml
put revCreateXMLTree(gxml,true,true,false) into txml
put revxmlnodecontents(txml,"GeocodeResponse/status") into geo["Status"]
**********************
******
repeat with I = 1 to
revxmlnumberofchildren(txml,"/GeocodeResponse/result","address_component",1)
switch revxmlnodecontents(txml,"GeocodeResponse/result/address_component["
& I & "]/type")
*******
******
put revXMLChildNames(txml,"/GeocodeResponse/result/geometry",comma,,false)
into str1
repeat for each item nodename in str1
switch nodename
Case "location"
put
revxmlnodecontents(txml,"GeocodeResponse/result/geometry/"&nodename&"/lat")
into geo["Lat"]["Center"]
*****
Ralph DiMola
IT Director
Evergreen Information Services
[email protected]
-----Original Message-----
From: use-livecode [mailto:[email protected]] On Behalf
Of Peter Hermsen
Sent: Friday, May 23, 2014 9:42 AM
To: [email protected]
Subject: XML Handling
Sorry for the long post. I'm trying to convert some programs from PHP to
livecode. I've been working with LiveCode for several years and haven't had
the opportunity to work with XML until now. I went through the LiveCode
lesson on reading from an XML file, but am running into problems when
working with live data. I used the example in:
http://lessons.runrev.com/s/lessons/m/4071/l/7011-How-to-read-in-data-from-a
n-XML-file
When I applied the same methods to my data, I can't retrieve my data values.
Instead, I get only "empty" and "xmlerr". If anybody could guide me in the
right direction, I'd really appreciate it. Here's an example data file:
<?xml version="1.0" encoding="UTF-8"?>
<orders>
<order>
<po_number>1111</po_number>
<ship_to>
<salutation>Mr</salutation>
<first_name>Joe</first_name>
<last_name>Smith</last_name>
<address_1>123 Street Rd.</address_1>
<address_2>Apartment 6</address_2>
<city>Some City</city>
<state>NJ</state>
<post_code>08810</post_code>
<email>[email protected]</email>
<phone>732-555-1212</phone>
<customer_ref_number>001</customer_ref_number>
</ship_to>
<items>
<item>
<line>1</line>
<sku>720912</sku>
<description>Widget</description>
<unit_price>24.50</unit_price>
<quantity>1</quantity>
</item>
</items>
</order>
<order>
<po_number>1112</po_number>
<ship_to>
<salutation>Ms</salutation>
<first_name>Jane</first_name>
<last_name>Doe</last_name>
<address_1>456 Raod St.</address_1>
<address_2>Some Suburb</address_2>
<city>My Little Town</city>
<state>NJ</state>
<post_code>08711</post_code>
<email>[email protected]</email>
<phone>609-555-1212</phone>
<customer_ref_number>002</customer_ref_number>
</ship_to>
<items>
<item>
<line>1</line>
<sku>060002</sku>
<description>Gizmo</description>
<unit_price>18.45</unit_price>
<quantity>1</quantity>
</item>
<item>
<line>2</line>
<sku>02134</sku>
<description>Thingy</description>
<unit_price>21.16</unit_price>
<quantity>1</quantity>
</item>
</items>
</order>
</orders>
Using PHP I can easily convert the above file to an Array. However,
LiveCode is being a bit more challenging.
Many thanks,
Pete Hermsen
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode