sax

SAX-based adapter to copy trees from/to the Python standard library.

Use the ElementTreeContentHandler class to build an ElementTree from SAX events.

Use the ElementTreeProducer class or the saxify() function to fire the SAX events of an ElementTree against a SAX ContentHandler.

See http://codespeak.net/lxml/sax.html

Module Contents

Classes

SaxError() General SAX error.
ElementTreeContentHandler(self,makeelement=None) Build an lxml ElementTree from SAX events.
ElementTreeProducer(self,element_or_tree,content_handler) Produces SAX events for an element and children.

Functions

_getNsTag(tag)
saxify(element_or_tree,content_handler) One-shot helper to generate SAX events from an XML tree and fire
class SaxError

General SAX error.

_getNsTag(tag)
class ElementTreeContentHandler(makeelement=None)

Build an lxml ElementTree from SAX events.

__init__(makeelement=None)
_get_etree()

“Contains the generated ElementTree after parsing is finished.”

setDocumentLocator(locator)
startDocument()
endDocument()
startPrefixMapping(prefix, uri)
endPrefixMapping(prefix)
_buildTag(ns_name_tuple)
startElementNS(ns_name, qname, attributes=None)
processingInstruction(target, data)
endElementNS(ns_name, qname)
startElement(name, attributes=None)
endElement(name)
characters(data)
class ElementTreeProducer(element_or_tree, content_handler)

Produces SAX events for an element and children.

__init__(element_or_tree, content_handler)
saxify()
_recursive_saxify(element, prefixes)
_build_qname(ns_uri, local_name, prefixes, new_prefixes)
saxify(element_or_tree, content_handler)

One-shot helper to generate SAX events from an XML tree and fire them against a SAX ContentHandler.