Home | Trees | Indices | Help |
|
---|
|
Version: 4.1.0
|
|||
AncestorsIterator AncestorsIterator(self, node, tag=None) Iterates over the ancestors of an element (from parent to parent). |
|||
AttributeBasedElementClassLookup AttributeBasedElementClassLookup(self, attribute_name, class_mapping, fallback=None) Checks an attribute of an Element and looks up the value in a class dictionary. |
|||
C14NError Error during C14N serialisation. |
|||
CDATA CDATA(data) |
|||
CommentBase All custom Comment classes must inherit from this one. |
|||
CustomElementClassLookup CustomElementClassLookup(self, fallback=None) Element class lookup based on a subclass method. |
|||
DTD DTD(self, file=None, external_id=None) A DTD validator. |
|||
DTDError Base class for DTD errors. |
|||
DTDParseError Error while parsing a DTD. |
|||
DTDValidateError Error while validating an XML document with a DTD. |
|||
DocInfo Document information provided by parser and DTD. |
|||
DocumentInvalid Validation error. |
|||
ETCompatXMLParser ETCompatXMLParser(self, encoding=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, schema=None, huge_tree=False, remove_blank_text=False, resolve_entities=True, remove_comments=True, remove_pis=True, strip_cdata=True, target=None, compact=True) |
|||
ETXPath ETXPath(self, path, extensions=None, regexp=True, smart_strings=True) Special XPath class that supports the ElementTree {uri} notation for namespaces. |
|||
ElementBase ElementBase(*children, attrib=None, nsmap=None, **_extra) |
|||
ElementChildIterator ElementChildIterator(self, node, tag=None, reversed=False) Iterates over the children of an element. |
|||
ElementClassLookup ElementClassLookup(self) Superclass of Element class lookups. |
|||
ElementDefaultClassLookup ElementDefaultClassLookup(self, element=None, comment=None, pi=None, entity=None) Element class lookup scheme that always returns the default Element class. |
|||
ElementDepthFirstIterator ElementDepthFirstIterator(self, node, tag=None, inclusive=True) Iterates over an element and its sub-elements in document order (depth first pre-order). |
|||
ElementNamespaceClassLookup ElementNamespaceClassLookup(self, fallback=None) |
|||
ElementTextIterator ElementTextIterator(self, element, tag=None, with_tail=True) Iterates over the text content of a subtree. |
|||
EntityBase All custom Entity classes must inherit from this one. |
|||
Error | |||
ErrorDomains Libxml2 error domains |
|||
ErrorLevels Libxml2 error levels |
|||
ErrorTypes Libxml2 error types |
|||
FallbackElementClassLookup FallbackElementClassLookup(self, fallback=None) |
|||
HTMLParser HTMLParser(self, encoding=None, remove_blank_text=False, remove_comments=False, remove_pis=False, strip_cdata=True, no_network=True, target=None, schema: XMLSchema =None, recover=True, compact=True, collect_ids=True) |
|||
HTMLPullParser HTMLPullParser(self, events=None, *, tag=None, base_url=None, **kwargs) |
|||
LxmlError Main exception base class for lxml. All other exceptions inherit from this one. |
|||
LxmlRegistryError Base class of lxml registry errors. |
|||
LxmlSyntaxError Base class for all syntax errors. |
|||
NamespaceRegistryError Error registering a namespace extension. |
|||
PIBase All custom Processing Instruction classes must inherit from this one. |
|||
ParseError Syntax error while parsing an XML document. |
|||
ParserBasedElementClassLookup ParserBasedElementClassLookup(self, fallback=None) Element class lookup based on the XML parser. |
|||
ParserError Internal lxml parser error. |
|||
PyErrorLog PyErrorLog(self, logger_name=None, logger=None) A global error log that connects to the Python stdlib logging package. |
|||
PythonElementClassLookup PythonElementClassLookup(self, fallback=None) Element class lookup based on a subclass method. |
|||
QName QName(text_or_uri_or_element, tag=None) |
|||
RelaxNG RelaxNG(self, etree=None, file=None) Turn a document into a Relax NG validator. |
|||
RelaxNGError Base class for RelaxNG errors. |
|||
RelaxNGErrorTypes Libxml2 RelaxNG error types |
|||
RelaxNGParseError Error while parsing an XML document as RelaxNG. |
|||
RelaxNGValidateError Error while validating an XML document with a RelaxNG schema. |
|||
Resolver This is the base class of all resolvers. |
|||
Schematron Schematron(self, etree=None, file=None) A Schematron validator. |
|||
SchematronError Base class of all Schematron errors. |
|||
SchematronParseError Error while parsing an XML document as Schematron schema. |
|||
SchematronValidateError Error while validating an XML document with a Schematron schema. |
|||
SerialisationError A libxml2 error that occurred during serialisation. |
|||
SiblingsIterator SiblingsIterator(self, node, tag=None, preceding=False) Iterates over the siblings of an element. |
|||
TreeBuilder TreeBuilder(self, element_factory=None, parser=None) Parser target that builds a tree. |
|||
XInclude XInclude(self) XInclude processor. |
|||
XIncludeError Error during XInclude processing. |
|||
XMLParser XMLParser(self, encoding=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, schema: XMLSchema =None, remove_blank_text=False, resolve_entities=True, remove_comments=False, remove_pis=False, strip_cdata=True, collect_ids=True, target=None, compact=True) |
|||
XMLPullParser XMLPullParser(self, events=None, *, tag=None, **kwargs) |
|||
XMLSchema XMLSchema(self, etree=None, file=None) Turn a document into an XML Schema validator. |
|||
XMLSchemaError Base class of all XML Schema errors |
|||
XMLSchemaParseError Error while parsing an XML document as XML Schema. |
|||
XMLSchemaValidateError Error while validating an XML document with an XML Schema. |
|||
XMLSyntaxError Syntax error while parsing an XML document. |
|||
XMLTreeBuilder ETCompatXMLParser(self, encoding=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, schema=None, huge_tree=False, remove_blank_text=False, resolve_entities=True, remove_comments=True, remove_pis=True, strip_cdata=True, target=None, compact=True) |
|||
XPath XPath(self, path, namespaces=None, extensions=None, regexp=True, smart_strings=True) A compiled XPath expression that can be called on Elements and ElementTrees. |
|||
XPathDocumentEvaluator XPathDocumentEvaluator(self, etree, namespaces=None, extensions=None, regexp=True, smart_strings=True) Create an XPath evaluator for an ElementTree. |
|||
XPathElementEvaluator XPathElementEvaluator(self, element, namespaces=None, extensions=None, regexp=True, smart_strings=True) Create an XPath evaluator for an element. |
|||
XPathError Base class of all XPath errors. |
|||
XPathEvalError Error during XPath evaluation. |
|||
XPathFunctionError Internal error looking up an XPath extension function. |
|||
XPathResultError Error handling an XPath result. |
|||
XPathSyntaxError | |||
XSLT XSLT(self, xslt_input, extensions=None, regexp=True, access_control=None) |
|||
XSLTAccessControl XSLTAccessControl(self, read_file=True, write_file=True, create_dir=True, read_network=True, write_network=True) |
|||
XSLTApplyError Error running an XSL transformation. |
|||
XSLTError Base class of all XSLT errors. |
|||
XSLTExtension Base class of an XSLT extension element. |
|||
XSLTExtensionError Error registering an XSLT extension. |
|||
XSLTParseError Error parsing a stylesheet document. |
|||
XSLTSaveError Error serialising an XSLT result. |
|||
_Attrib A dict-like proxy for the Element.attrib property. |
|||
_BaseErrorLog | |||
_Comment | |||
_Document Internal base class to reference a libxml document. |
|||
_DomainErrorLog | |||
_Element Element class. |
|||
_ElementIterator Dead but public. :) |
|||
_ElementMatchIterator | |||
_ElementStringResult | |||
_ElementTagMatcher Dead but public. :) |
|||
_ElementTree | |||
_ElementUnicodeResult | |||
_Entity | |||
_ErrorLog | |||
_FeedParser | |||
_IDDict IDDict(self, etree) A dictionary-like proxy class that mapps ID attributes to elements. |
|||
_ListErrorLog Immutable base version of a list based error log. |
|||
_LogEntry A log message entry from an error log. |
|||
_ProcessingInstruction | |||
_RotatingErrorLog | |||
_SaxParserTarget | |||
_TargetParserResult | |||
_Validator Base class for XML validators. |
|||
_XPathEvaluatorBase | |||
_XSLTProcessingInstruction | |||
_XSLTResultTree The result of an XSLT evaluation. |
|||
htmlfile htmlfile(self, output_file, encoding=None, compression=None, close=False, buffered=True) |
|||
iterparse iterparse(self, source, events=("end",), tag=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, remove_blank_text=False, remove_comments=False, remove_pis=False, encoding=None, html=False, recover=None, huge_tree=False, schema=None) |
|||
iterwalk iterwalk(self, element_or_tree, events=("end",), tag=None) |
|||
xmlfile xmlfile(self, output_file, encoding=None, compression=None, close=False, buffered=True) |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
DEBUG = 1
|
|||
LIBXML_COMPILED_VERSION =
|
|||
LIBXML_VERSION =
|
|||
LIBXSLT_COMPILED_VERSION =
|
|||
LIBXSLT_VERSION =
|
|||
LXML_VERSION =
|
|||
__package__ = None hash(x) |
|||
__pyx_capi__ =
|
|||
__test__ =
|
|||
memory_debugger = <lxml.etree._MemDebug object>
|
|
Element factory. This function returns an object implementing the Element interface. Also look at the _Element.makeelement() and
|
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. |
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. Usage: >>> ns_functions = FunctionNamespace("http://schema.org/Movie") >>> @ns_functions # uses function name ... def add2(x): ... return x + 2 >>> @ns_functions("add3") # uses explicit name ... def add_three(x): ... return x + 3 |
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, ...). |
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 = XML("<root><test/></root>") >>> print(root.tag) 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, ...). |
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. |
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). Smart strings will be returned for string results unless you pass smart_strings=False. |
Unpack a libxml2 document pointer from a PyCapsule and wrap it in an lxml ElementTree object. This allows external libraries to build XML/HTML trees using libxml2 and then pass them efficiently into lxml for further processing. Requires Python 2.7 or later. If a parser is provided, it will be used for configuring the lxml document. No parsing will be done. The capsule must have the name "libxml2:xmlDoc" and its pointer value must reference a correct libxml2 document of type xmlDoc*. The creator of the capsule must take care to correctly clean up the document using an appropriate capsule destructor. By default, the libxml2 document will be copied to let lxml safely own the memory of the internal tree that it uses. If the capsule context is non-NULL, it must point to a C string that can be compared using strcmp(). If the context string equals "destructor:xmlFreeDoc", the libxml2 document will not be copied but the capsule invalidated instead by clearing its destructor and name. That way, lxml takes ownership of the libxml2 document in memory without creating a copy first, and the capsule destructor will not be called. The document will then eventually be cleaned up by lxml using the libxml2 API function xmlFreeDoc() once it is no longer used. If no copy is made, later modifications of the tree outside of lxml should not be attempted after transferring the ownership. |
Remove all namespace declarations from a subtree that are not used by any of the elements or attributes in that tree. If a 'top_nsmap' is provided, it must be a mapping from prefixes to namespace URIs. These namespaces will be declared on the top element of the subtree before running the cleanup, which allows moving namespace declarations to the top of the tree. If a 'keep_ns_prefixes' is provided, it must be a list of prefixes. These prefixes will not be removed as part of the cleanup. |
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. |
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, ...). |
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. |
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:
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. |
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 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. |
Delete all attributes with the provided attribute names from an Element (or ElementTree) and its descendants. Attribute names can contain wildcards as in _Element.iter. Example usage: strip_attributes(root_element, 'simpleattr', '{http://some/ns}attrname', '{http://other/ns}*') |
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. Tag names can contain wildcards as in _Element.iter. 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. Example usage: strip_elements(some_element, 'simpletagname', # non-namespaced tag '{http://some/ns}tagname', # namespaced tag '{http://some/other/ns}*' # any tag from a namespace lxml.etree.Comment # comments ) |
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. Tag names can contain wildcards as in _Element.iter. 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. Example usage: strip_tags(some_element, 'simpletagname', # non-namespaced tag '{http://some/ns}tagname', # namespaced tag '{http://some/other/ns}*' # any tag from a namespace Comment # comments (including their text!) ) |
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 keyword argument 'pretty_print' (bool) enables formatted XML. The keyword argument 'method' selects the output method: 'xml', 'html', plain 'text' (text content without tags) or 'c14n'. Default is 'xml'. 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. |
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. |
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 boolean keyword argument 'pretty_print' enables formatted XML. The keyword argument 'method' selects the output method: 'xml', 'html' or plain 'text'. 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. Deprecated: use tostring(el, encoding='unicode') instead. |
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. Note: prior to lxml 2.2, this changed the error log globally. Since lxml 2.2, the global error log is local to a thread and this function will only set the global error log of the current thread. |
|
__pyx_capi__
|
__test__
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Oct 13 15:46:58 2017 | http://epydoc.sourceforge.net |