Entity(name)
Entity factory. This factory function creates a special element
that will be serialized as an XML entity reference or character
reference. Note, however, that entities will not be automatically
declared in the document. A document that uses entity references
requires a DTD to define the entities.

Extension(module,
function_mapping=None,
ns=None)
Build a dictionary of extension functions from the functions
defined in a module or the methods of an object.

FunctionNamespace(ns_uri)
Retrieve the function namespace object associated with the given
URI.

HTML(text,
parser=None,
base_url=None)
Parses an HTML document from a string constant. Returns the root
node (or the result returned by a parser target). This function
can be used to embed "HTML literals" in Python code.

PI(target,
text=None)
ProcessingInstruction element factory. This factory function creates a
special element that will be serialized as an XML processing instruction.

ProcessingInstruction(target,
text=None)
ProcessingInstruction element factory. This factory function creates a
special element that will be serialized as an XML processing instruction.

SubElement(_parent,
_tag,
attrib=None,
nsmap=None,
**_extra)
Subelement factory. This function creates an element instance, and
appends it to an existing element.

XML(text,
parser=None,
base_url=None)
Parses an XML document or fragment from a string constant.
Returns the root node (or the result returned by a parser target).
This function can be used to embed "XML literals" in Python code,
like in

XMLDTDID(text,
parser=None,
base_url=None)
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.

XMLID(text,
parser=None,
base_url=None)
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(etree_or_element,
namespaces=None,
extensions=None,
regexp=True,
smart_strings=True)
Creates an XPath evaluator for an ElementTree or an Element.

cleanup_namespaces(tree_or_element)
Remove all namespace declarations from a subtree that are not used
by any of the elements or attributes in that tree.

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

dump(elem,
pretty_print=True,
with_tail=True)
Writes an element tree or element structure to sys.stdout. This function
should be used for debugging only.

fromstring(text,
parser=None,
base_url=None)
Parses an XML document or fragment from a string. Returns the
root node (or the result returned by a parser target).

fromstringlist(strings,
parser=None)
Parses an XML document from a sequence of strings. Returns the
root node (or the result returned by a parser target).

get_default_parser()

iselement(element)
Checks if an object appears to be a valid element object.

parse(source,
parser=None,
base_url=None)
Return an ElementTree object loaded with source elements. If no parser
is provided as second argument, the default parser is used.

parseid(source,
parser=None)
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.

register_namespace(...)
Registers a namespace prefix that newly created Elements in that
namespace will use. The registry is global, and any existing
mapping for either the given prefix or the namespace URI will be
removed.

set_default_parser(parser=None)
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.

strip_attributes(tree_or_element,
*attribute_names)
Delete all attributes with the provided attribute names from an
Element (or ElementTree) and its descendants.

strip_elements(tree_or_element,
with_tail=True,
*tag_names)
Delete all elements with the provided tag names from a tree or
subtree. This will remove the elements and their entire subtree,
including all their attributes, text content and descendants. It
will also remove the tail text of the element unless you
explicitly set the with_tail keyword argument option to False.

strip_tags(tree_or_element,
*tag_names)
Delete all elements with the provided tag names from a tree or
subtree. This will remove the elements and their attributes, but
not their text/tail content or descendants. Instead, it will
merge the text content and children of the element into its
parent.

Element(_tag,
attrib=None,
nsmap=None,
**_extra)

Also look at the _Element.makeelement() and
_BaseParser.makeelement() methods, which provide a faster way to
create an Element within a specific document or parser context.

Extension(module,
function_mapping=None,
ns=None)

Build a dictionary of extension functions from the functions
defined in a module or the methods of an object.

As second argument, you can pass an additional mapping of
attribute names to XPath function names, or a list of function
names that should be taken.

The ns keyword argument accepts a namespace URI for the XPath
functions.

FunctionNamespace(ns_uri)

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.

HTML(text,
parser=None,
base_url=None)

Parses an HTML document from a string constant. Returns the root
node (or the result returned by a parser target). 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, ...).

XML(text,
parser=None,
base_url=None)

Parses an XML document or fragment from a string constant.
Returns the root node (or the result returned by a parser target).
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(text,
parser=None,
base_url=None)

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.

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). Smart strings will be returned for string results unless
you pass smart_strings=False.

clear_error_log()

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

Note: since lxml 2.2, the global error log is local to a thread
and this function will only clear the global error log of the
current thread.

fromstring(text,
parser=None,
base_url=None)

Parses an XML document or fragment from a string. Returns the
root node (or the result returned by a parser target).

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

fromstringlist(strings,
parser=None)

Parses an XML document from a sequence of strings. Returns the
root node (or the result returned by a parser target).

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

parse(source,
parser=None,
base_url=None)

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

The source can be any of the following:

a file name/path

a file object

a file-like object

a URL using the HTTP or FTP protocol

To parse from a string, use the fromstring() function instead.

Note that it is generally faster to parse from a file path or URL
than from an open file object or file-like object. Transparent
decompression from gzip compressed sources is supported (unless
explicitly disabled in libxml2).

The base_url keyword allows setting a URL for the document
when parsing from a file-like object. This is needed when looking
up external entities (DTD, XInclude, ...) with relative paths.

parseid(source,
parser=None)

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.

set_default_parser(parser=None)

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.

strip_attributes(tree_or_element,
*attribute_names)

Delete all attributes with the provided attribute names from an
Element (or ElementTree) and its descendants.

strip_elements(tree_or_element,
with_tail=True,
*tag_names)

Delete all elements with the provided tag names from a tree or
subtree. This will remove the elements and their entire subtree,
including all their attributes, text content and descendants. It
will also remove the tail text of the element unless you
explicitly set the with_tail keyword argument option to False.

Note that this will not delete the element (or ElementTree root
element) that you passed even if it matches. It will only treat
its descendants. If you want to include the root element, check
its tag name directly before even calling this function.

strip_tags(tree_or_element,
*tag_names)

Delete all elements with the provided tag names from a tree or
subtree. This will remove the elements and their attributes, but
not their text/tail content or descendants. Instead, it will
merge the text content and children of the element into its
parent.

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.

You can also serialise to a Unicode string without declaration by
passing the unicode function as encoding (or str in Py3),
or the name 'unicode'. This changes the return value from a byte
string to an unencoded unicode string.

The exclusive and with_comments arguments are only used
with C14N output, where they request exclusive and uncommented
C14N serialisation respectively.

Passing a boolean value to the standalone option will output
an XML declaration with the corresponding standalone flag.

The doctype option allows passing in a plain string that will
be serialised before the XML tree. Note that passing in non
well-formed content here will make the XML output non well-formed.
Also, an existing doctype in the document tree will not be removed
when serialising an ElementTree instance.

You can prevent the tail text of the element from being serialised
by passing the boolean with_tail option. This has no impact
on the tail text of children, which will always be serialised.

tostringlist(element_or_tree,
*args,
**kwargs)

Serialize an element to an encoded string representation of its XML
tree, stored in a list of partial strings.

This is purely for ElementTree 1.3 compatibility. The result is a
single string wrapped in a list.

__test__

Value:

{u'XML (line 2951)': u'''XML(text, parser=None, base_url=None) Parses an XML document or fragment from a string constant. Returns the root node (or the result returned by a parser target). This function can be used to embed "XML literals" in Python code, like in >>> root = etree.XML("<root><test/></root>")...