XML::Struct::Simple - Transform MicroXML data structures into simple (unordered) form
my $micro = [ root => { xmlns => 'http://example.org/' }, [ '!', [ x => {}, [42] ] ] ]; my $converter = XML::Struct::Simple->new( root => 'record' ); my $simple = $converter->transform( $micro ); # { record => { xmlns => 'http://example.org/', x => 42 } }
This module implements a transformation from structured XML (MicroXML) to simple key-value format (SimpleXML) as known from XML::Simple: Attributes and child elements are treated as hash keys with their content as value. Text elements without attributes are converted to text and empty elements without attributes are converted to empty hashes.
XML::Struct can export the function simpleXML for easy use. Function readXML and XML::Struct::Reader apply transformation to SimpleXML with option simple.
simpleXML
readXML
simple
Transform XML given as array reference (MicroXML) to XML as hash reference (SimpleXML) as configured.
Transform child nodes and attributes of an XML element given as array reference at a given depth (0 by default). Returns a hash reference, a scalar, or the element unmodified.
0
Keep the root element instead of removing. This corresponds to option KeepRoot in XML::Simple. In addition a non-numeric value can be used to override the name of the root element. Disabled by default.
KeepRoot
Include XML attributes. Enabled by default. The special value remove is equivalent to false. Corresponds to option NoAttr in XML::Simple.
remove
NoAttr
Name of a field to put text content in. Set to "content by default. Corresponds to option ContentKey in XML::Simple.
content
ContentKey
Only transform up to a given depth. Set to a negative value by default for unlimited depth. Elements below depth are not cloned but copied by reference. Depth 0 will return the element unmodified.
Option KeyAttr, ForceArray, and other fetures of XML::Simple not supported. Options NsExpand and NsStrip supported in XML::LibXML::Simple are not supported yet.
KeyAttr
ForceArray
NsExpand
NsStrip
To install XML::Struct, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Struct
CPAN shell
perl -MCPAN -e shell install XML::Struct
For more information on module installation, please visit the detailed CPAN module installation guide.