From: Steve B. <Ste...@zv...> - 2002-08-28 11:15:08
|
Derek Fountain wrote: > I have a parent node which has a whole bunch of children. Each child has a > number of sub-nodes, and can be quite large. I want to change the order of > the children under the parent node. That is, this: > > <parent> > <child>1</child> > <child>2</child> > <child>3</child> > </parent> > > might become this: > > <parent> > <child>2</child> > <child>1</child> > <child>3</child> > </parent> > > What's the most efficient way to do that? I'm using TclDOM and Use the 'insertBefore' method of the dom::node command. Ie. get the token of the child you want to move, the token of the node you want to move the node in front of, and the token of the parent. Then: dom::node insertBefore $parent $moving $inFrontOfMe This method automatically updates the tree to make the move happen. It works no matter where in the tree $moving was originally. HTHs, Steve Ball -- Steve Ball | XSLT Standard Library | Training & Seminars Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development Ste...@zv... +---------------------------+--------------------- Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099 |