Package lxml :: Module etree
[show private | hide private]
[frames | no frames]

Module lxml.etree

Classes
AncestorsIterator Iterates over the ancestors of an element (from parent to parent).
AttributeBasedElementClassLookup Checks an attribute of an Element and looks up the value in a class dictionary.
CommentBase All custom Comment classes must inherit from this one.
CustomElementClassLookup Element class lookup based on a subclass method.
DocInfo Document information provided by parser and DTD.
DTD A DTD validator.
ElementBase All custom Element classes must inherit from this one.
ElementChildIterator Iterates over the children of an element.
ElementClassLookup Superclass of Element class lookups.
ElementDefaultClassLookup Element class lookup scheme that always returns the default Element class.
ElementDepthFirstIterator Iterates over an element and its sub-elements in document order (depth first pre-order).
ElementNamespaceClassLookup Element class lookup scheme that searches the Element class in the Namespace registry.
EntityBase All custom Entity classes must inherit from this one.
ETCompatXMLParser An XML parser with an ElementTree compatible default setup.
ETXPath Special XPath class that supports the ElementTree {uri} notation for namespaces.
FallbackElementClassLookup Superclass of Element class lookups with additional fallback.
HTMLParser The HTML parser.
iterparse Incremental parser.
iterwalk A tree walker that generates events from an existing tree as if it was parsing XML data with ``iterparse()``.
ParserBasedElementClassLookup Element class lookup based on the XML parser.
PIBase All custom Processing Instruction classes must inherit from this one.
PyErrorLog A global error log that connects to the Python stdlib logging package.
QName QName wrapper.
RelaxNG Turn a document into a Relax NG validator.
Resolver This is the base class of all resolvers.
Schematron A Schematron validator.
SiblingsIterator Iterates over the siblings of an element.
XMLParser The XML parser.
XMLSchema Turn a document into an XML Schema validator.
XPath A compiled XPath expression that can be called on Elements and ElementTrees.
XPathDocumentEvaluator Create an XPath evaluator for an ElementTree.
XPathElementEvaluator Create an XPath evaluator for an element.
XSLT Turn a document into an XSLT object.
XSLTAccessControl Access control for XSLT: reading/writing files, directories and network I/O.
__ContentOnlyElement  
_Attrib  
_AttribIterator Attribute iterator - for internal use only!
_BaseContext  
_BaseErrorLog  
_BaseParser  
_ClassNamespaceRegistry Dictionary-like registry for namespace implementation classes
_Comment  
_Document Internal base class to reference a libxml document.
_DomainErrorLog  
_Element Element class.
_ElementIterator  
_ElementTagMatcher  
_ElementTree  
_Entity  
_ErrorLog  
_ExceptionContext  
_ExsltRegExp  
_FilelikeWriter  
_FileParserContext  
_FunctionNamespaceRegistry  
_IDDict A dictionary-like proxy class that mapps ID attributes to elements.
_InputDocument  
_IterparseContext  
_ListErrorLog Immutable base version of a list based error log.
_LogEntry  
_NamespaceRegistry Dictionary-like namespace registry
_ParserContext  
_ProcessingInstruction  
_ResolverContext  
_ResolverRegistry  
_RotatingErrorLog  
_TempStore  
_Validator Base class for XML validators.
_XPathContext  
_XPathEvaluatorBase  
_XPathFunctionNamespaceRegistry  
_XSLTContext  
_XSLTProcessingInstruction  
_XSLTResolverContext  
_XSLTResultTree  

Function Summary
  clearErrorLog(...)
Clear the global error log.
  Comment(...)
Comment element factory.
  dump(...)
Writes an element tree or element structure to sys.stdout.
  Element(...)
Element factory.
  ElementTree(...)
ElementTree wrapper class.
  Entity(...)
Entity factory.
  Extension(...)
  fromstring(...)
Parses an XML document from a string.
  FunctionNamespace(...)
Retrieve the function namespace object associated with the given URI.
  get_default_parser(...)
  getDefaultParser(...)
Deprecated, please use get_default_parser instead.
  HTML(...)
Parses an HTML document from a string constant.
  iselement(...)
Checks if an object appears to be a valid element object.
  parse(...)
Return an ElementTree object loaded with source elements.
  parseid(...)
Parses the source into a tuple containing an ElementTree object and an ID dictionary.
  PI(...)
ProcessingInstruction element factory.
  ProcessingInstruction(...)
ProcessingInstruction element factory.
  set_default_parser(...)
Set a default parser for the current thread.
  set_element_class_lookup(...)
Set the global default element class lookup method.
  setDefaultParser(...)
Deprecated, please use set_default_parser instead.
  setElementClassLookup(...)
Deprecated, use ``set_element_class_lookup(lookup)`` instead
  SubElement(...)
Subelement factory.
  tostring(...)
Serialize an element to an encoded string representation of its XML tree.
  tounicode(...)
Serialize an element to the Python unicode representation of its XML tree.
  useGlobalPythonLog(...)
Replace the global error log by an etree.PyErrorLog that uses the standard Python logging package.
  XML(...)
Parses an XML document from a string constant.
  XMLDTDID(...)
Parse the text and return a tuple (root node, ID dictionary).
  XMLID(...)
Parse the text and return a tuple (root node, ID dictionary).
  XPathEvaluator(...)
Creates an XPath evaluator for an ElementTree or an Element.

Variable Summary
str __version__ = '2.0.dev-45843'
int DEBUG = 1                                                                     
tuple LIBXML_COMPILED_VERSION = (2, 6, 27)
tuple LIBXML_VERSION = (2, 6, 27)
tuple LIBXSLT_COMPILED_VERSION = (1, 1, 20)
tuple LIBXSLT_VERSION = (1, 1, 20)
tuple LXML_VERSION = (2, 0, -300, 45843)
PyCObject _import_c_api = <PyCObject object at 0x401cb428>

Function Details

clearErrorLog(...)

Clear the global error log. Note that this log is already bound to a fixed size.

Comment(...)

Comment element factory. This factory function creates a special element that will be serialized as an XML comment.

dump(...)

Writes an element tree or element structure to sys.stdout. This function should be used for debugging only.

Element(...)

Element factory. This function returns an object implementing the Element interface.

ElementTree(...)

ElementTree wrapper class.

Entity(...)

Entity factory. This factory function creates a special element that will be serialized as an XML entity. Note, however, that the entity will not be automatically declared in the document. A document that uses entities requires a DTD.

fromstring(...)

Parses an XML document from a string.

To override the default parser with a different parser you can pass it to the ``parser`` keyword argument.

The ``base_url`` keyword argument allows to set the original base URL of the document to support relative Paths when looking up external entities (DTD, XInclude, ...).

FunctionNamespace(...)

Retrieve the function namespace object associated with the given URI. Creates a new one if it does not yet exist. A function namespace can only be used to register extension functions.

getDefaultParser(...)

Deprecated, please use get_default_parser instead.

HTML(...)

Parses an HTML document from a string constant. This function can be used to embed "HTML literals" in Python code.

To override the parser with a different ``HTMLParser`` you can pass it to the ``parser`` keyword argument.

The ``base_url`` keyword argument allows to set the original base URL of the document to support relative Paths when looking up external entities (DTD, XInclude, ...).

iselement(...)

Checks if an object appears to be a valid element object.

parse(...)

Return an ElementTree object loaded with source elements. If no parser is provided as second argument, the default parser is used.

parseid(...)

Parses the source into a tuple containing an ElementTree object and an ID dictionary. If no parser is provided as second argument, the default parser is used.

Note that you must not modify the XML tree if you use the ID dictionary. The results are undefined.

PI(...)

ProcessingInstruction element factory. This factory function creates a special element that will be serialized as an XML processing instruction.

ProcessingInstruction(...)

ProcessingInstruction element factory. This factory function creates a special element that will be serialized as an XML processing instruction.

set_default_parser(...)

Set a default parser for the current thread. This parser is used globally whenever no parser is supplied to the various parse functions of the lxml API. If this function is called without a parser (or if it is None), the default parser is reset to the original configuration.

Note that the pre-installed default parser is not thread-safe. Avoid the default parser in multi-threaded environments. You can create a separate parser for each thread explicitly or use a parser pool.

set_element_class_lookup(...)

Set the global default element class lookup method.

setDefaultParser(...)

Deprecated, please use set_default_parser instead.

setElementClassLookup(...)

Deprecated, use ``set_element_class_lookup(lookup)`` instead

SubElement(...)

Subelement factory. This function creates an element instance, and appends it to an existing element.

tostring(...)

Serialize an element to an encoded string representation of its XML tree.

Defaults to ASCII encoding without XML declaration. This behaviour can be configured with the keyword arguments 'encoding' (string) and 'xml_declaration' (bool). Note that changing the encoding to a non UTF-8 compatible encoding will enable a declaration by default.

The keyword argument 'pretty_print' (bool) enables formatted XML.

tounicode(...)

Serialize an element to the Python unicode representation of its XML tree.

Note that the result does not carry an XML encoding declaration and is therefore not necessarily suited for serialization to byte streams without further treatment.

The keyword argument 'pretty_print' (bool) enables formatted XML.

useGlobalPythonLog(...)

Replace the global error log by an etree.PyErrorLog that uses the standard Python logging package.

Note that this disables access to the global error log from exceptions. Parsers, XSLT etc. will continue to provide their normal local error log.

XML(...)

Parses an XML document from a string constant. This function can be used to embed "XML literals" in Python code, like in
>>> root = etree.XML("<root><test/></root>")

To override the parser with a different ``XMLParser`` you can pass it to the ``parser`` keyword argument.

The ``base_url`` keyword argument allows to set the original base URL of the document to support relative Paths when looking up external entities (DTD, XInclude, ...).

XMLDTDID(...)

Parse the text and return a tuple (root node, ID dictionary). The root node is the same as returned by the XML() function. The dictionary contains string-element pairs. The dictionary keys are the values of ID attributes as defined by the DTD. The elements referenced by the ID are stored as dictionary values.

Note that you must not modify the XML tree if you use the ID dictionary. The results are undefined.

XMLID(...)

Parse the text and return a tuple (root node, ID dictionary). The root node is the same as returned by the XML() function. The dictionary contains string-element pairs. The dictionary keys are the values of 'id' attributes. The elements referenced by the ID are stored as dictionary values.

XPathEvaluator(...)

Creates an XPath evaluator for an ElementTree or an Element.

The resulting object can be called with an XPath expression as argument and XPath variables provided as keyword arguments.

Additional namespace declarations can be passed with the 'namespace' keyword argument. EXSLT regular expression support can be disabled with the 'regexp' boolean keyword (defaults to True).

Variable Details

__version__

Type:
str
Value:
'2.0.dev-45843'                                                        

DEBUG

Type:
int
Value:
1                                                                     

LIBXML_COMPILED_VERSION

Type:
tuple
Value:
(2, 6, 27)                                                             

LIBXML_VERSION

Type:
tuple
Value:
(2, 6, 27)                                                             

LIBXSLT_COMPILED_VERSION

Type:
tuple
Value:
(1, 1, 20)                                                             

LIBXSLT_VERSION

Type:
tuple
Value:
(1, 1, 20)                                                             

LXML_VERSION

Type:
tuple
Value:
(2, 0, -300, 45843)                                                    

_import_c_api

Type:
PyCObject
Value:
<PyCObject object at 0x401cb428>                                       

Generated by Epydoc 2.1 on Sat Aug 18 12:44:28 2007 http://epydoc.sf.net