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

Module lxml.etree

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.
  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.
  Namespace(...)
Retrieve the namespace object associated with the given URI.
  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(...)
Comment element factory.
  ProcessingInstruction(...)
Comment element factory.
  set_default_parser(...)
Set a default parser for the current thread.
  setDefaultParser(...)
Deprecated, please use set_default_parser instead.
  setElementClassLookup(...)
  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__ = '1.3.3-45352'
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 = (1, 3, 3, 45352)
PyCObject _import_c_api = <PyCObject object at 0x401c34e8>

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.

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.

Namespace(...)

Retrieve the namespace object associated with the given URI. Creates a new one if it does not yet exist.

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(...)

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

ProcessingInstruction(...)

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

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.

setDefaultParser(...)

Deprecated, please use set_default_parser 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.

XPath evaluators must not be shared between threads.

Variable Details

__version__

Type:
str
Value:
'1.3.3-45352'                                                          

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:
(1, 3, 3, 45352)                                                       

_import_c_api

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

Generated by Epydoc 2.1 on Thu Jul 26 19:14:08 2007 http://epydoc.sf.net