Previous topic

libearth.compat — Compatibility layer

Next topic

libearth.xml.compat.clrxmlreader — XML parser implementation for CLR

This Page

libearth.compat.etree — ElementTree compatibility layer

This proxy module offers a compatibility layer between several ElementTree implementations.

It provides the following two functions:

libearth.compat.etree.fromstring(string)

Parse the given XML string.

Parameters:string (str, bytes, basestring) – xml string to parse
Returns:the element tree object
libearth.compat.etree.fromstringlist(iterable)

Parse the given chunks of XML string.

Parameters:iterable (collections.Iterable) – chunks of xml string to parse
Returns:the element tree object
libearth.compat.etree.tostring(tree)

Generate an XML string from the given element tree.

Parameters:tree – an element tree object to serialize
Returns:an xml string
Return type:str, bytes
libearth.compat.etree.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, ...).

libearth.compat.etree.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.

Fork me on GitHub