XML::Struct implements a mapping between XML and Perl data structures. By default, the mapping preserves element order, so it also suits for "document-oriented" XML. In short, an XML element is represented as array reference with three parts:

[ $name => \%attributes, \@children ]

This data structure corresponds to the abstract data model of MicroXML, a simplified subset of XML.

If your XML documents don't contain relevant attributes, you can also choose to map to this format:

Read an XML document with XML::Struct::Reader. The type of source (string, filename, URL, IO Handle...) is detected automatically. Options not known to XML::Struct::Reader are passed to XML::LibXML::Reader.

Transform an XML document/element into simple key-value format 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. The following options are supported:

This module also supports a simple key-value (aka "data-oriented") format, as used by XML::Simple. With option simple (or function simpleXML) the document given above woule be transformed to this structure: