This question ia about writing XML data from a LiveCode stack to a file. Chapter 6.7 of the User's guide talks about the XML functions LiveCode provides. I am looking for examples which show how to construct an XML file and write it to a disk file.
http://support.runrev.com/tutorials/xmldemo.rev.gz is a tutorial stack about how to use the revNNN XML functions of LiveCode.
It has an example
....
local tDocID, tParentNode, tSubNode
-- get the document ID for the current XML tree
put fld "DocID" into tDocID
-- specify the root node for the XML tree
put "/employeeTable" into tParentNode
revAddXMLNode tDocID, tParentNode, "employee", ""
put the result into tSubNode
-- add the IDnum attribute to the newly created data record
revSetXMLAttribute tDocID, tSubNode, "IDnum", "1"
-- add the remaining data elements, checking for error after each addition
revAddXMLNode tDocID, tSubNode, "firstName", "Steve"
revAddXMLNode tDocID, tSubNode, "lastName", "Jobs"
revAddXMLNode tDocID, tSubNode, "roomNum", "001"
revAddXMLNode tDocID, tSubNode, "phoneExt", "345"
revAddXMLNode tDocID, tSubNode, "parkingSlot", 100
The result
<?xml version="1.0"?>
<employeeTable>
<employee IDnum="1">
<firstName>Steve</firstName>
<lastName>Jobs</lastName>
<roomNum>001</roomNum>
<phoneExt>345</phoneExt>
<parkingSlot>100</parkingSlot>
</employee>
</employeeTable>
Are there libraries which make writing XML texts easier by providing convenience functions so that I do not need to keep track of nodes when adding nested structures?
Something like
startXML "theEmployees.xml" -- gives the file name
startTag "employeetable"
startTag "employee"
addAttribute "IDnum", 1
startTag "firstName"
writeContent "Steve"
closeTag
-- or
writeNode "lastname", "Jobs"
writeNode "roomnum", "001"
-- ....
closeTag -- employee
closeTag -- employeeTable
closeXML
It is relatively easy to write a couple of functions like this but the question is. Are there established ways of writing out XML text to a file in LiveCode?