xmlgeneric

New in version 1.1.3.

A generic, universal XML serializer with read and write capabilities.

The format is inspired by plist and http://msdn.microsoft.com/en-us/library/bb924435.aspx

Example

{
  "string": "Doodah",
  "integer": 728,
  "float": 0.1,
  "date": datetime.now(),
  "items": ["A", "B", 12, 32.1, [1, 2, 3, None]],
  "dict": {
    "str": "<hello & hi there!>",
    "unicode": u'M\xe4ssig, Ma\xdf',
    "true value": True,
    "false value": False,
  ),
  "data": data("<binary gunk>"),
  "more_data": data("<lots of binary gunk>" * 10)
}
<?xml version="1.0" encoding="utf-8"?>
<dict>
  <string k="string">Doodah</string>
  <int k="integer">728</int>
  <real k="float">0.1</real>
  <date k="date">2009-02-22T15:46:39Z</date>
  <array k="items">
    <string>A</string>
    <string>B</string>
    <int>12</int>
    <real>32.1</real>
    <array>
      <int>1</int>
      <int>2</int>
      <int>3</int>
      <null />
    </array>
  </array>
  <dict k="dict">
    <false k="false value" />
    <true k="true value" />
    <string k="unicode">Mässig, Maß</string>
    <string k="str">&lt;hello &amp; hi there!&gt;</string>
  </dict>
  <data k="data">PGJpbmFyeSBndW5rPg==</data>
  <data k="more_data">
    PGxvdHMgb2YgYmluYXJ5IGd1bms+PGxvdHMgb2YgYmluYXJ5IGd1bms+PGxvdHMgb2YgYmluYXJ5
    IGd1bms+PGxvdHMgb2YgYmluYXJ5IGd1bms+PGxvdHMgb2YgYmluYXJ5IGd1bms+PGxvdHMgb2Yg
    YmluYXJ5IGd1bms+PGxvdHMgb2YgYmluYXJ5IGd1bms+PGxvdHMgb2YgYmluYXJ5IGd1bms+PGxv
    dHMgb2YgYmluYXJ5IGd1bms+PGxvdHMgb2YgYmluYXJ5IGd1bms+
  </data>
</dict>

Classes

class smisk.serialization.xmlgeneric.GenericXMLSerializer(smisk.serialization.xmlbase.XMLSerializer)

Inherits from XMLSerializer

See documentation of smisk.serialization.Serializer for details on inherithed methods and how to interface with serializers.

name
Value:“Generic XML”
extensions
Value:(“xml”,)
media_types
Value:(“text/xml”,)
charset
Value:“utf-8”
can_serialize
Value:True
can_unserialize
Value:True
build_object(parent, name, value, set_key=True)
Serialize an object.
parse_object(elem)
Unserialize an object.
serialize(params, charset):
See smisk.serialization.Serializer.serialize() for more information.
unserialize(file, length=-1, charset=None):
See smisk.serialization.Serializer.unserialize() for more information.
exception smisk.serialization.xmlgeneric.GenericXMLUnserializationError(smisk.serialization.xmlbase.XMLUnserializationError)
Raised when trying to unserialize invalid documents.