这个问题关于将XML数据从LiveCode堆栈写入文件。 用户指南的第6.7章讨论了LiveCode提供的XML函数。我正在寻找示例来展示如何构建XML文件并将其写入磁盘文件。如何构建和编写XML文件?
http://support.runrev.com/tutorials/xmldemo.rev.gz是关于如何使用LiveCode的revNNN XML功能的教程堆栈。
它有一个例子
....
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
结果
<?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>
是否有库,这使得通过提供方便的功能编写XML文本更容易让我不需要跟踪节点加入时嵌套结构?
喜欢的东西
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
这是比较容易写这样一对夫妇的功能,但问题是。是否已经建立了将XML文本写入LiveCode文件的方法?
这是由Mark Wieder(公共领域)提供的版本控制库,它包含一些XML编写过程。 http://revonline2.runrev.com/stack/686/libVersionControl – 2013-05-06 09:53:40
在我的书“为真正的初学者编写LiveCode”中有一章关于创建和读取XML文件。 – Mark 2013-06-15 11:19:34