XML Handling

Peter Hermsen hermsen at comcast.net
Fri May 23 09:42:29 EDT 2014


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-an-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>joe at smith.com</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>jane at bigserver.com</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




More information about the use-livecode mailing list