Ok just a comment here, that might clarify some confusion (or might not, who knows!).
AFAIK there are two ways of building up a XML "thing" within a GEL script - for the sake of argument I'm going to call these two ways "inline" and "xpath" (whether these terms are strictly right, I don't know!).
I use the "inline" method, only because that was the first way that I encountered so I am just used to it - the code Gene posted is the "xpath" method - I suspect that the "xpath" way is the right/better way to do things, but a lot of examples on these discussion boards (including anything that I've ever posted) probably uses the "inline" method.
How the two methods differ I'll try to explain in pseudo-code - example of building an XML based on some query results;
--
"Inline" - the XML is built up inline in the GEL script and the code goes something like this;
Open a XML document ( this is the start of the gel:parse tag)
Write some XML header information to the document - do this just by including the XML text inline into the GEL script
Open a query on the database;
Start to loop around the results from the query
each result line from the query write a record to the XML document - again just include the relevant text inline in the GEL
Finish loop
Close the XML document (this is the end of the gel:parse tag)
--
"Xpath" - we create a XML document and use xpath to add things to it;
Create (i.e. open and close) an empty, but fully formed XML document (this is the whole 'open' gel:parse and close 'gel:parse')
use Xpath syntax to write some data to the XML document
Open a query on the database;
Start to loop around the results from the query
each result line from the query use Xpath syntax to insert the data to the XML document
Finish loop
--
I guess the personal differences might just come down to what you are familiar with ; in the "inline" way we have to make sure that the XML/XOG syntax that we are putting inline into the GEL script is syntactically correct (from an XML/XOG point of view), with the "xpath" way we don't have to worry so much about the XML syntax (since XPath/XML just takes care of that) but the xpath syntax itself I find can be a bit hard to get right.
(@Keri - so the 'solution' that I gave to your loop question was very much an "inline" way of doing things, Gene's posted solution is the "xpath" way)
YMMV...