pugixml.pugi.BytesWriter

class pugixml.pugi.BytesWriter

Bases: XMLWriter

XMLWriter implementation for bytes.

See also

XMLNode.print()

Examples

>>> from pugixml import pugi
>>> doc = pugi.XMLDocument()
>>> doc.append_child('node')
>>> writer = pugi.BytesWriter()
>>> doc.print(writer, flags=pugi.FORMAT_RAW, encoding=pugi.ENCODING_UTF32_BE)
>>> writer.getvalue().decode('utf-32be')
'<node/>'

Methods

__init__(self)

Initialize BytesWriter.

__len__(self)

Return the contents size in bytes.

getvalue(self)

Return the entire contents of the buffer.

Member Documentation

__init__(self: pugixml.pugi.BytesWriter) None

Initialize BytesWriter.

__len__(self: pugixml.pugi.BytesWriter) int

Return the contents size in bytes.

Returns:

The contents size in bytes.

getvalue(self: pugixml.pugi.BytesWriter) bytes

Return the entire contents of the buffer.

Returns:

The entire contents of the buffer.