hyperboreean wrote: > Hi, I am writing the application server for a three-tier architecture > and sending the client's response in xml. My question is: is there a way > to build the xml dom in a more scalable way and faster way than just > creating every textNode and element for it? I have tons of data to > transmit and it drives me crazy having to build that dom manually. > > I am not sure if this is a stupid question as I don't know other > alternatives ... maybe just provide a template xml which I can fill with > data but that can introduce some pretty ugly bugs in the application.
You should have a look at the ElementTree-package (which also comes api-compatible as lxml). These allow for a much more pythonic way of creating XML-trees. However you might consider using a much more concise format such as json for transport (if you have control over the client). It reduces the data-amount to about a tenth or so (of course depending on your xml-dialect), with considerable gains in processing time. And then there in fact are some template languages such as KID and genshi that might suit you because they enforce proper XML. Diez -- http://mail.python.org/mailman/listinfo/python-list