Book Image

LiveCode Mobile Development Cookbook

By : Dr. Edward Lavieri
Book Image

LiveCode Mobile Development Cookbook

By: Dr. Edward Lavieri

Overview of this book

Table of Contents (17 chapters)
LiveCode Mobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Reading XML


XML (Extensible Markup Language) files represent an organized method to save and quickly read information from files.

How to do it...

Use the following steps to read the XML data:

  1. Create a new main stack in LiveCode.

  2. Set the background color of the main card to black.

  3. Drag a new button to the card and assign the following properties:

    • Name: btn_readXML

    • Label: Read XML

    • threeD: Keep it unchecked

    • showBorder: Keep it unchecked

    • hiliteBorder: Keep it unchecked

    • backgroundColor: White

  4. Create a text file with the following text. Save the file as sample.xml into the documents folder on your mobile device:

    <sample>
      <language>English</language>
      <timeZone>ET</timeZone> 
    </sample>
  5. Assign the following code to the btn_readXML button:

    on mouseUp
      local xmlTree, tLanguage
      
      # Read XML File into memory
      put readXMLtoTree() into xmlTree
      
      # Retrieve specific piece of information
      put revXMLNodeContents(xmlTree, "sample/language") into tLanguage
      
      # Release...