The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Simple::SAX::Serializer - Simple XML serializer

DESCRIPTION

Represents xml serializer class,

SYNOPSIS

    use Simple::SAX::Serializer;
    my $xml = Simple::SAX::Serializer;

    $xml->handler('root/child', sub {
        my ($self, $element, $parent) = @_;
        my $attributes = $element->attributes;
        my $result = $parent->children_array_result;
        push @$result,Child->new(%$attributes);
    });

    $xml->handler('root', sub {
        my ($self, $element) = @_;
          $element->validate_attributes(['dummy'], {attr2 => 'default_value'});
          Root->new(%{$element->attributes}, children => $element->children_result);
    });

    my $xml_content = "<?xml version="1.0"?><root dummy="1"><child id="1" ><child id="2" ></root>";

    $xml->parse_string($xml_content);
    # or $xml->parse_file ...

ATTRIBUTES

handlers

METHODS

parse_string

Runs the parser and returns result, xml as string

parse_file

Runs the parser and returns result, xml as file

parse

Runs the parser and returns result

find_handlder

Finds handler for current element. It start matching from root/element/searched_element and if not find that it try to resolve by element/searched_element and eventually searched_element If handler is not found then generates an error.

element_path

Takes array reference of the elements data structures, return list of element name.

COPYRIGHT AND LICENSE

The Simple::SAX::Serializer module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

SEE ALSO

Simple::SAX::Serializer::Parser XML::LibXML::SAX

AUTHOR

Adrian Witas, adrian@webapp.strefa.pl

See also