Catmandu::Importer::XML - Import serialized XML documents
version 0.07
This importer reads XML and transforms it into a data structure.
By default (type "simple"), elements and attributes and converted to keys in a key-value structure. For instance this document:
simple
<doc attr="value"> <field1>foo</field1> <field1>bar</field1> <bar> <doz>baz</doz> </bar> </doc>
is imported as
{ attr => 'value', field1 => [ 'foo', 'bar' ], field2 => { 'doz' => 'baz' }, }
With type "ordered" elements are preserved in the order of their appereance. For instance the sample document above is imported as:
ordered
[ doc => { attr => "value" }, [ [ field1 => { }, ["foo"] ], [ field1 => { }, ["bar"] ], [ field2 => { }, [ [ doz => { }, ["baz"] ] ] ] ] ]
Maximum depth for type "simple". For instance with depth 1, the sample document above would be imported as:
{ attr => 'value', field1 => [ 'foo', 'bar' ], field2 => { doz => [ [ doz => { }, ["baz"] ] ] } }
Include XML attributes. Enabled by default.
Path expression to select XML elements. If not set the root element is selected.
Include root element name, if enabled. Disabled by default, unless the path option is set.
path
Set to 'strip' for stripping namespace prefixes and xmlns-attributes.
strip
Include ignoreable whitespace. Disabled by default.
This module is just a thin layer on top of XML::Struct::Reader. Have a look at XML::Struct to implement Importers and Exporters for more specific XML-based data formats.
Jakob Voß
This software is copyright (c) 2014 by Jakob Voß.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Catmandu::XML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu::XML
CPAN shell
perl -MCPAN -e shell install Catmandu::XML
For more information on module installation, please visit the detailed CPAN module installation guide.