I am new to lxml. I am interested to know the equivalent code using
lxml (http://cheeseshop.python.org/pypi/lxml/1.1alpha). The code is
taken from http://effbot.org/zone/xml-writer.htm

from elementtree.SimpleXMLWriter import XMLWriter
import sys

w = XMLWriter(sys.stdout)

html = w.start("html")

w.start("head")
w.element("title", "my document")
w.element("meta", name="generator", value="my application 1.0")
w.end()

w.start("body")
w.element("h1", "this is a heading")
w.element("p", "this is a paragraph")

w.start("p")
w.data("this is ")
w.element("b", "bold")
w.data(" and ")
w.element("i", "italic")
w.data(".")
w.end("p")

w.close(html)

Best Regards,
Srijit

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to