Codec for serialising and de-serialising XML data. Supports both array and objects for mapping into resources or collections of resources.
dump(fp, resource, line_ending=u'')¶
Dump a resource to a file like object. :param fp: File pointer or file like object. :param resource: Resource to dump :param line_ending:
Dump a resource to a string.
Parameters: resource – Resource to dump Returns:
There is no direct representation for a
Loading a resource from a file:
from odin.codecs import xml_codec with open('my_resource.xml') as f: resource = xml_codec.load(f)
Saving a resource to a file:
from odin.codecs import xml_codec with open('my_resource.xml', 'w') as f: xml_codec.dump(f, resource)