Navigating through added XML data?

Peter T. Evensen pevensen at
Wed Mar 29 19:32:21 EST 2006

If you have an XML Tree, you can add nodes using revAddXMLNode, put data 
into the node using revPutIntoXMLNode and then use revXMLText(tXMLTree) to 
save the text to a file name.

Here is a function I created to add data to an arbitrary node in an 
existing tree (it creates all the nodes, if they do not exist, but assumes 
the root node exists):

on SaveToXMLTree TreeID, Path, Data
   if TreeID is a number then
     -- see if the node exists
     set the itemDelimiter to "/"
     repeat with i = 2 to the number of items in Path - 1
       put item 1 to i of Path into startNode
       put item i+1 of Path into node
       if revXMLChildNames(TreeID,startNode,"",node,false) is empty then
         revAddXMLNode TreeID, startNode, node, ""
         if the result contains "xmlerr" then
           ReportError "Error adding node" && item 1 to i+1 of Path && "to 
XML Tree:" && the result
         end if
       end if
     end repeat
     set the itemDelimiter to ","
     if the platform is "MacOS" then
       put the MacToISO of Data into Data
     end if
     revPutIntoXMLNode TreeID,Path,Data
     if the result contains "xmlerr" then
       ReportError "Error adding data to node" && Path && ":" && the result
     end if
   end if
end SaveToXMLTree

At 05:59 PM 3/29/2006, you wrote:
>Hello All...
>I'm trying to learn to use XML to store stack data. I've managed to load 
>an existing XML document into the stack, navigate through XML data using 
>revXMLMatchingNode and revXMLChildContents and placing contents in 
>specific flds, and creating additonal data using revSetXMLAttribute and 
>So far so good. However, ultimatley I want to be able to continue 
>navigating through the XML data including any new data that has been entered.
>I can see that the additional data has been added by using 
>revXMLChildContents, however I don't know how to save the results of 
>revXMLChildContents back into the stack as a XML file, and thus enabling 
>navigation through the appended XML file.
>I had been trying to do it using  revCreateXMLTree but it errors because 
>revXMLChildContents does not return a proper XML format.
>Any suggestions?
>Thank you!
>John Patten
>use-revolution mailing list
>use-revolution at
>Please visit this url to subscribe, unsubscribe and manage your 
>subscription preferences:

Peter T. Evensen
314-629-5248 or 888-628-4588 

More information about the Use-livecode mailing list