[Keith Vetter] 2005-03-21 : Recently I had to optimize some code that was using pure-tcl to extract out each element of an XML file in the order it appears in the file. My first step in optimization was simply to use [tdom] to build a dom tree. Then, the following code does a restartable pre-order traversal of that tree The first call to ''':::WalkXML::NextNode''' with XML data initializes the dom tree. Each subsequent call to '''::WalkXML::NextNode''' returns the next dom node. Just this optimization alone, without redoing the code to utilize the dom tree, greatly speeded up the processing. [NEM] ''21Mar05'': If you want to walk the elements in the order they appear in the file, might a [SAX] interface be just what you are after? [KPV] Close, but the two models differ in who drives whom. The SAX model makes repeated calls into user code via callbacks while in this model works user code makes repeated calls into the this model. For parsing XML, I find the second way better fitting my mental model of how it should work: e.g. I'm looking at a ''