On Fri, 2 Jun 2000, Joshua D. Boyd wrote:
> I'm having trouble with inserted nodes into the tree. I have the
> following code:
>
> def BuildTree (tree, parent, element):
> if element.firstChild==None:
> node = tree.insert_node(parent, None, element.nodeName)
> else:
> node = tree.insert_node(parent, None, element.nodeName,
> is_leaf=FALSE)
> print element.nodeName + ": " + `element.nodeValue`
> for n in element.childNodes:
> if n.nodeType == 1 or n.nodeType == 3:
> BuildTree(tree, node, n)
>
>
> element.nodeName is a string. The print statement prints the full
> nodename, but both of the tree.insert_node statements insert a node
> consisting of only the first character of the string. Any ideas on why
> this might be?
As a ctree can have multiple columns, the third argument to insert_node is
a sequence of strings giving the column values. A string is a sequence,
and its sequence items are the characters in the string. Try using
[element.nodeName] instead.
>
> --
> Joshua Boyd
> http://catpro.dragonfire.net/joshua
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
-
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]