Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

convert data structures to/from XML

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Build.PL
Octocat-spinner-32 Changes
Octocat-spinner-32 MANIFEST
Octocat-spinner-32 MANIFEST.SKIP
Octocat-spinner-32 README
    Data::asXML - convert data structures to/from XML

        use Data::asXML;
        my $dxml = Data::asXML->new();
        my $dom = $dxml->encode({
            'some' => 'value',
            'in'   => [ qw(a data structure) ],

        my $data = $dxml->decode(q{
                <KEY name="some"><VALUE>value</VALUE></KEY>
                <KEY name="in">

        my (%hash1, %hash2);
        print Data::asXML->new->encode([1, \%hash1, \%hash2])->toString;
                        <KEY name="other">
                                        <KEY name="other">
                                                <HASH href="../../../../*[2]"/>
            <HASH href="*[2]/*[1]/*[1]"/>

    For more examples see t/01_Data-asXML.t.

    experimental, use on your own risk :-)

    There are couple of modules mapping XML to data structures.
    (XML::Compile, XML::TreePP, XML::Simple, ...) but they aim at making
    data structures adapt to XML structure. This one defines couple of
    simple XML tags to represent data structures. It makes the serialization
    to and from XML possible.

    For the moment it is an experiment. I plan to use it for passing data
    structures as DOM to XSLT for transformations, so that I can match them
    with XPATH similar way how I access them in Perl.


    If you are looking for a module to serialize your data, without
    requirement to do so in XML, you should probably better have a look at
    JSON::XS or Storable.

        (default 1 - true) will insert text nodes to the XML to make the
        output indented.

        (default undef - false)

        in case of `encode()' perform the xml string decoding back and will
        compare the two data structures to be sure the data can be
        reconstructed back without errors.

        in case of a `decode()' it will decode to data then encode to xml
        string and from xml string decode back to data. this two data values
        are then compared.

        Both compares is done using Test::Deep::NoTest::eq_deeply.

        (default undef - false)

        adds xml:ns attribute to the root element. if `namespace' is set to
        1 the xml:ns will be
        otherwise it will be the value of `namespace'.

    Object constructor.

    From structure `$what' generates XML::LibXML::Document DOM. Call
    `->toString' to get XML string. For more actions see XML::LibXML.

    Takes `$xmlstring' and converts to data structure.

    Jozef Kutej, `<jkutej at>'

    The following people have contributed to the Sys::Path by commiting
    their code, sending patches, reporting bugs, asking questions,
    suggesting useful advices, nitpicking, chatting on IRC or commenting on
    my blog (in no particular order):

        Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
        Emmanuel Rodriguez

        * int, float encoding ? (string enough?)
        * XSD
        * anyone else has an idea?
        * what to do with blessed? do the same as JSON::XS does?

    Please report any bugs or feature requests to `bug-data-asxml at', or through the web interface at I will be
    notified, and then you'll automatically be notified of progress on your
    bug as I make changes.

    You can find documentation for this module with the perldoc command.

        perldoc Data::asXML

    You can also look for information at:

    * RT: CPAN's request tracker

    * AnnoCPAN: Annotated CPAN documentation

    * CPAN Ratings

    * Search CPAN

    Copyright 2009 Jozef Kutej.

    This program is free software; you can redistribute it and/or modify it
    under the terms of either: the GNU General Public License as published
    by the Free Software Foundation; or the Artistic License.

    See for more information.

Something went wrong with that request. Please try again.