這個問題關於將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