Navigating through added XML data?

Sarah Reichelt sarah.reichelt at
Wed Mar 29 22:26:33 EST 2006

> 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 revAddXMLNode.
> 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.

An XML file is just plain text with tag markers. When you read it into
Rev and call revCreateXMLTree or use revCreateXMLTreeFromFile, this
creates an internal data structure - the XML tree.

You can edit the tree using the revAddXMLNode, revSetXMLAttribute etc
functions and the internal data tree is updated every time. However
your original disk file will not be changed unless you manually save
the text form of the XML data to it.

To do this, you need to use revXMLText(treeID). This gives you plain
text, although it is not formatted neatly. To get a slightly
better-looking display, use this:  revXMLText(treeID,,true)
Yes, there are 2 commas there. The second parameter can be used to
specify the starting node if you don't want to convert all the tree to
text. The third parameter is undocumented, but if "true", it does some
formatting of the text.

Once you have the text, you can save it to a text file using the
normal URL commands.

For further information, you may be interested in my XML tutorial at


More information about the Use-livecode mailing list