pyx12.xmlwriter¶
Classes¶
Doctest: |
Module Contents¶
- class pyx12.xmlwriter.XMLWriter(out=sys.stdout, encoding='utf-8', indent=' ')[source]¶
Doctest:
>>>from xmlwriter import XMLWriter >>>writer = XMLWriter() >>>writer.doctype( … u”xsa”, u”-//LM Garshol//DTD XML Software Autoupdate 1.0//EN//XML”, … u”https://www.garshol.priv.no/download/xsa/xsa.dtd”) >>>#Notice: there is no error checking to ensure that the root element >>>#specified in the doctype matches the top-level element generated >>>writer.push(u”xsa”) >>>#Another element with child elements >>>writer.push(u”vendor”) >>>#Element with simple text (#PCDATA) content >>>writer.elem(u”name”, u”Centigrade systems”) >>>writer.elem(u”email”, u”info@centigrade.bogus”) >>>writer.elem(u”vendor”, u”Centigrade systems”) >>>#Close currently open element (“vendor) >>>writer.pop() >>>#Element with an attribute >>>writer.push(u”product”, {u”id”: u”100u00B0”}) >>>writer.elem(u”name”, u”100u00B0 Server”) >>>writer.elem(u”version”, u”1.0”) >>>writer.elem(u”last-release”, u”20030401”) >>>#Empty element >>>writer.empty(u”changes”) >>>writer.pop() >>>writer.pop()
startElement endElement emptyElement text, data endDocument attribute indentation close flush
out - a stream for the output encoding - an encoding used to wrap the output for unicode indent - white space used for indentation