XMLSerializer


Attributes

a decl

True

a encoding

'utf-8'

a doctype

None

a formatted

False

a src_encoding

'utf-8'

a namespaces

{'http://purl.org/atom/ns#': 'atom',
 'http://purl.org/rss/1.0/': 'rss',
 'http://www.w3.org/1999/02/22-rdf-syntax-ns#': 'rdf',
 'http://www.w3.org/1999/xhtml': 'html',
 'http://www.w3.org/XML/1998/namespace': 'xml'}

a format

Format(simple_newlines=True)

a inline

False

a entity_map

None

Methods

f is_formatted(self, tagname) ...

f is_inline(self, tagname) ...

f serialize(self, stream, encoding=None, fragment=False, format=None) ...

f write(self, stream, file, encoding=None, fragment=False, format=None) ...

f apply_filters(self, stream, format=None) ...

f format_stream(self, stream, format) ...

Apply format to stream.

Note that this method is unaware of the serialization of the tags and does only take into account the text inside the stream. So the results may sometimes differ from what you expect when formatting the complete serialized output.

f __init__(self, encoding=None, decl=None, doctype=None, entity_map=None, namespaces=None, formatted=None, inline=None, format=None) ...

Initialize XMLSerializer.

You can change the following parameters:

encoding: the output encoding decl: add xml declaration at the beginning (True/False) doctype: add doctype (None, string, tuple) entity_map: use named entities for output (True/False or mapping) namespaces: mapping of namespaces formatted: whether all tags should be considered formatted inline: whether all tags should be considered inline format: format to be applied (string or instance of Format)

f can_be_empty_element(self, item_name) ...

f generate(self, stream, encoding=None, fragment=False, format=None) ...

Serializes an event stream to bytes of the specified encoding.

This function yields an encoded string over and over until the stream is exhausted.

f escape_cdata(text, encoding=None, entity_map=None) ...

Escape character data.

f escape_attrib(text, encoding=None, entity_map=None) ...

Escape attribute value.

See the source for more information.