Package genshi :: Module output |

# Module output

This module provides different kinds of serialization methods for XML event streams.

Classes
| DocType Defines a number of commonly used DOCTYPE declarations as constants.
| XMLSerializer Produces XML text from an event stream.
| XHTMLSerializer Produces XHTML text from an event stream.
| HTMLSerializer Produces HTML text from an event stream.
| TextSerializer Produces plain text from an event stream.

Functions
encode(iterator, method=`'``xml``'`, encoding=`'``utf-8``'`, out=None) Encode serializer output into a string. |
get_serializer(method=`'``xml``'`, **kwargs) Return a serializer object for the given method. |

Function Details

### encode(iterator, method=`'``xml``'`, encoding=`'``utf-8``'`, out=None) |
Encode serializer output into a string. Parameters: `iterator` - the iterator returned from serializing a stream (basically any iterator that yields unicode objects) `method` - the serialization method; determines how characters not representable in the specified encoding are treated `encoding` - how the output string should be encoded; if set to `None`, this method returns a `unicode` object `out` - a file-like object that the output should be written to instead of being returned as one big string; note that if this is a file or socket (or similar), the `encoding` must not be `None` (that is, the output must be encoded) Returns: a `str` or `unicode` object (depending on the `encoding` parameter), or `None` if the `out` parameter is provided Since: version 0.4.1 Note: Changed in 0.5: added the `out` parameter

### get_serializer(method=`'``xml``'`, **kwargs) |
Return a serializer object for the given method. Any additional keyword arguments are passed to the serializer, and thus depend on the `method` parameter value. Parameters: `method` - the serialization method; can be either "xml", "xhtml", "html", "text", or a custom serializer class See Also: XMLSerializer, XHTMLSerializer, HTMLSerializer, TextSerializer Since: version 0.4.1