Inserting XML nodes

Sumner,Walt WSUMNER at im.wustl.edu
Tue Dec 13 18:18:38 EST 2005


Does anyone know of a clean way to insert a child among a list of XML child
nodes in a tree, rather than appending the node at the end of the parent
node's list of children?  I am using an XML structure to store data during
and between user sessions, and ultimately to communicate with other programs.
There are a lot of optional paths through the tree, but I think their order
needs to be maintained. I can make the tree very verbose by enumerating all
of the optional paths and leaving them empty, but would rather insert paths
as needed. I don't see that the Rev library supports this directly. I have a
transcript method to move a child in a list, but it works by deleting
children and appending them back as needed - pretty terrible.

Example problems:

1. Insert "B" as Child[2] in this tree structure to create a list in the
order A, B, C, without removing the current Child[2]

     ParentList[1]
                  Child[1] //contains "A"
                  Child[2] //contains "C"

2. Insert MiddleInitial[1] = "W" between FirstName and LastName in this tree
structure without removing the LastName[1] child

    Name[1]
             FirstName[1] //contains "George"
             LastName[1] //contains "Bush"

Any insights would be welcome.

Walt Sumner



More information about the use-livecode mailing list