[Grok-dev] XML output using a page template?
faassen at startifact.com
Sun Feb 20 05:45:48 EST 2011
On 02/16/2011 08:40 AM, Sascha Boch wrote:
> Quick question - I'd like to use a page template to output XML data. How do I do this?
Just as a note: I tend not to use page templates for this at all, but
instead use lxml's facilities: the E constructor is useful, along with
things like SubElement.
That's not to say a template language cannot be used for this
successfully, but I'd just like to point out an alternative.
Stuff like this:
from lxml.builder import E
from lxml import etree
foo = E.foo("blah")
bqar = E.bar("something", some_attr="hoi")
return etree.tostring(foo, encoding='UTF-8')
More information about the Grok-dev