The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

Object::Relation::Format::XML - The Object::Relation XML serialization class

Synopsis

use Object::Relation::Format::XML;
my $formatter = Object::Relation::Format::XML->new;
my $xml      = $formatter->serialize($obj_rel_object);
my $object    = $formatter->deserialize($xml);

Description

This class is used for serializing and deserializing Object::Relation objects to and from XML. New objects may be created or existing objects may be updated using this class.

Constructors

new

my $xml = Object::Relation::Format::XML->new;
# or
my $xml = Object::Relation::Format::XML->new({
  pretty => 1,
  indent => 2,
});

Creates and returns a new XML format object. It optionally takes a Object::Relation::Base object as an argument. This is equivalent to:

If preferred, a hashref may be passed as an argument. Keys are:

  • pretty

    Whether to use newlines between XML elements.

  • indent

    Indentation level (in spaces) for nested XML elements.

As a general rule, you will want to call new without arguments. This ensures a more compact XML representation, thus saving bandwidth.

content_type

my $content_type = $formatter->content_type;

Returns the MIME content type for the current format.

ref_to_format

my $xml = $formatter->ref_to_format($reference);

Converts an arbitrary reference to its XML equivalent.

format_to_ref

my $reference = $formatter->format_to_ref($xml);

Converts XML to its equivalent Perl reference.

Copyright and License

Copyright (c) 2004-2006 Kineticode, Inc. <info@obj_relode.com>

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.