The elementtree.ElementC14N Module

_find_open_uris(elem, scope, parent) [#]

(Internal) Finds undefined URI:s in a scoped tree.

_findprefix(elem, scope, parent, uri) [#]

(Internal) Finds prefix for given URI in a scoped tree.

_listscopes(elem, scope, parent) [#]

(Internal) Returns a sequence of (prefix, uri) pairs.

_serialize_c14n(write, elem, encoding, qnames, namespaces) [#]

(Internal) Hook used by ElementTree's c14n output method

parse(file) [#]

Parses an XML file, and builds a tree annotated with scope and parent information. To parse from a string, use the StringIO module.

A file name or file object.
An extended ElementTree, with extra scope and parent information attached to the ElementTree object.

write(elem, file, subset=None, **options) [#]

Writes a canonicalized document.

Element or ElementTree. If passed a tree created by parse, the function attempts to preserve existing prefixes. Otherwise, new prefixes are allocated.
Output file. Can be either a filename or a file-like object.
Subset element, if applicable.
Options, given as keyword arguments.
Use exclusive C14N. In this mode, namespaces declarations are moved to the first element (in document order) that actually uses the namespace.
If given, a list or set of prefxies that should be retained in the serialized document, even if they're not used. This applies to exclusive serialization only (for inclusive subsets, all prefixes are always included).