DOMOutput creates Document Object Model (DOM) (implemented in Python by xml.dom) structures.
Usage Example:
>>> from xml.dom.minidom import getDOMImplementation
>>> dom_br = getDOMImplementation().createDocument(None, 'br', None).documentElement
>>> dom_output = DOMOutput()
>>> from ecoxipy import MarkupBuilder
>>> b = MarkupBuilder(dom_output)
>>> xml_doc = b[:'section':True] (
... b.section(
... b.p(b & 'Hello World!'),
... None,
... b(u'<p>äöüß</p>'),
... b.p('<&>'),
... b(
... '<raw/>text', b.br,
... (i for i in range(3)), (i for i in range(3, 6)), dom_br
... ),
... b | '<This is a comment!>',
... b['pi-target':'<PI content>'],
... b['pi-without-content':],
... attr='\'"<&>'
... )
... )
>>> document_string = u"""<?xml version="1.0" ?><!DOCTYPE section><section attr="'"<&>"><p>Hello World!</p><p>äöüß</p><p><&></p><raw/>text<br/>012345<br/><!--<This is a comment!>--><?pi-target <PI content>?><?pi-without-content ?></section>"""
>>> xml_doc.toxml() == document_string
True
An Output implementation which creates xml.dom nodes.
Parameters: | dom_implementation (xml.dom.DOMImplementation) – The DOM implementation to use to create xml.dom.Node instances. If this is None xml.dom.minidom.getDOMImplementation() is used. |
---|
Tests if an object has the attribute nodeType and is thus a xml.dom.Node instance.
Returns: | True for objects having the attribute nodeType. |
---|
Returns a DOM element representing the created element.
Return type: | xml.dom.Element |
---|