Provides functions to recursively walk a DOM or Domlette object and
generate SAX-like event calls for each node encountered. See the
printer classes (XMLPrinter, HTMLPrinter, etc.) for the event
handlers.
- __init__(self, stream, encoding, nsHints=None, isHtml=False, indent=False, canonical=False, addedAttributes=None, removedNsDecls=None)
-
Initializes an instance of the class, selecting the appropriate
printer to use, depending on the isHtml and indent flags.
nsHints, if given, is a dictionary of namespace mappings that
help determine if namespace declarations need to be emitted when
visiting the first Element node.
- visit(self, node)
-
Starts walking the tree at the given node.
- visitAttribute(self, node)
-
Called when an Attribute node is encountered. Generates an
attribute event for the printer.
- visitCDATASection(self, node)
-
Called when a CDATASection node is encountered. Generates a
cdataSection event for the printer.
- visitComment(self, node)
-
Called when a Comment node is encountered. Generates a comment
event for the printer.
- visitDocument(self, node)
-
Called when a Document node is encountered. Just proceeds to the
associated DocumentType node, if any, and then to the node's
children.
- visitDocumentFragment(self, node)
-
Called when a DocumentFragment node is encountered. Just
proceeds to the node's children.
- visitDocumentType(self, node)
-
Called when a DocumentType node is encountered. Generates a
doctype event for the printer.
- visitElement(self, node)
-
Called when an Element node is encountered. Generates for the
printer a startElement event, events for the node's children
(including attributes), and an endElement event.
- visitNotImplemented(self, node)
-
Called when an known but unsupported type of node is
encountered, always raising a NotImplementedError exception. The
unsupported node types are those that require DTD subset
support: entity nodes, entity reference nodes, and notation
nodes.
- visitProcessingInstruction(self, node)
-
Called when a ProcessingInstruction node is encountered.
Generates a processingInstruction event for the printer.
- visitText(self, node)
-
Called when a Text node is encountered. Generates a text event
for the printer.