XML::Struct::Simple(3pm) | User Contributed Perl Documentation | XML::Struct::Simple(3pm) |
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".
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.
Option "KeyAttr", "ForceArray", and other fetures of XML::Simple not supported. Options "NsExpand" and "NsStrip" supported in XML::LibXML::Simple are not supported yet.
2019-02-21 | perl v5.28.1 |