Title: Message
Thank you very much John, this was exactly what I needed. I expanded MyNode class based on your implementation and it worked well.
 
However, I encountered another issue when removing a tree node at runtime, I had a command button that removes a tree node when clicked. In fact the node was removed from the tree but the tree wasn't updated on the browser, I'm thinking of calling a method to redraw or refresh the treenode or the container object. Do you have any idea on this?
 
{let cbRemoveNode:CommandButton =
{CommandButton
    label = "Remove Node",
    {on Action do
        {treeNode1.nodes.remove 0}
    }
}
}
Best regards,
Thu
-----Original Message-----
From: John Chisholm [mailto:[EMAIL PROTECTED]
Sent: Sunday, August 15, 2004 5:21 AM
To: [EMAIL PROTECTED]
Subject: Re: I need help on TreeNode object and XML parser

 
I've attached an applet file and a sample XML data file. I think they demonstrate what you're asking for. I've assumed that you're using the core Curl API and not the Curl Starter Kit (CSK), so the parsing code uses the SAXParser API directly. Some notes:
 
- This is just one quick implementation. It isn't likely to be the optimal implementation ;-)
- This implementation requires privilege to read and write data to the filesystem
- Much of the parsing code is drawn from the Surge Lab documentation - search for "SAX, interface for xml parsers"
- MyNode is a user-defined class
- {MyNode.to-XML} and {MyNode.get-child-string} are pretty dumb. I didn't bother doing anything to format or indent the output.
- I honestly don't know much about TreeNodes, but the class seems to be unsupported and mostly for internal use. The way I've modified the tree to remove a node was by removing the node from the TreeNode's nodes member, which the documentation explicitly recommends against. If there is a better way, I haven't taken the time to find it yet :-[
 
The bottom line is that this is a quick hack from which I think you'll probably figure out a few things but I wouldn't expect much more from it than that :-)
 
Cheese
 
----- Original Message -----
Sent: Saturday, August 14, 2004 12:01 AM
Subject: I need help on TreeNode object and XML parser

Hello,
 
Currently I'm facing some problems with CURL:
+ How to parse data from a XML file and store this data in a TreeNode object?
+ How to export the TreeNode object data back to a XML file?
 
Also please have a look at my code below:
{let root:TreeNode = {TreeNode label="Root element"},
treeNode1 = {TreeNode label="111"},
treeNode2 = {TreeNode label="222"},
treeNode11 = {TreeNode label="11"},
treeNode21 = {TreeNode label="21"},
treeNode31 = {TreeNode label="31"}
}
 
{value
{root.add treeNode1}
{root.add treeNode2}
{treeNode1.add treeNode11}
{treeNode11.add treeNode21}
root
}
I'm trying to build a simple tree by adding its nodes and this code works very well. However I can't remove a node using {treeNode1.clear} or {treeNode1.detach}
What should I do to remove a node and its children from a TreeNode object?
 
I really appreciate any help.
 
Thanks,
Thu

Reply via email to