Catman...er::XML(3pm)
π NAME π
okay so bestie, welcome to the manual page for Catman...er::XML(3pm) β which is the doc page for Catmandu::Importer::XML (yes the header spells it all weird like that, we don't question it, we just vibe) π
and it imports serialized XML documents.
β¨ DESCRIPTION β¨
This Catmandu::Importer reads XML and transforms it into a data structure. Like, it takes your crunchy angle brackets and gives you... structure. iconic behavior fr fr π¦
Also, peep Catmandu::Importer, Catmandu::Iterable, Catmandu::Logger and Catmandu::Fixable for the methods and options derived from these modules. that's where the rest of the lore lives π
And lowkey the best part? The importer can also be used internally for custom importers that need to parse XML data. main character energy for your own modules π
πΈ CONFIGURATION πΈ
here's where we set the vibes. every option, no skips, no cap:
π type
By default (type ""simple""), elements and attributes get converted to keys in a key-value structure. For instance this document:
<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:
[
doc => { attr => "value" }, [
[ field1 => { }, ["foo"] ],
[ field1 => { }, ["bar"] ],
[ field2 => { }, [ [ doz => { }, ["baz"] ] ] ]
]
]
so yeah β "simple" gives you the tidy little hash, "ordered" gives you the β¨chronological receiptsβ¨ of everything in the order it showed up. pick your fighter π₯
π¦ depth
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"] ] ]
}
}
ngl it's giving "how deep do you wanna go" and the answer is literally a number π
π attributes
Include XML attributes. Enabled by default. so you're already getting them unless you say otherwise π
π path
Path expression to select XML elements. If not set the root element is selected. like, choose your own adventure but for XML nodes π§
π
π root
Include root element name for type "simple". Disabled by default. The option is ignored if type is not "simple" or if a "path" has explicitly been set.
β οΈ fr fr read that twice: if your type isn't"simple", or if you set a"path"yourself, this option just gets straight up ignored. it's not being rude, it's just the rules π
π§ ns
Set to "strip" for stripping namespace prefixes and xmlns-attributes. bye bye prefixes πβ¨
β whitespace
Include ignoreable whitespace. Disabled by default. (yes, "ignoreable" β that's the spelling in the original, we keep it exactly, no edits bestie π)
π xslt
Optional (list of) XSLT stylesheets to process records with Catmandu::XML::Transformer. glow-up pipeline for your records π₯
π transform
Deprecated alias for option "xslt".
π¨ deprecated means deprecated!! it's the old name, "xslt" is the moment now. use that one, periodt.
π SEE ALSO π
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.
like, it's the cute lil jacket over the actual engine β and if you wanna build your own XML-flavored importers/exporters, XML::Struct is where you go π«Ά
and that's the whole page bestie!! ππβ¨
cute lil sign-off: this was perl v5.36.0, dated 2022-09-15, filed under Catman...er::XML(3pm) β slay, go parse something pretty πΈπ¦π
π¦ where this page comes from
- ubuntu noble: libcatmandu-xml-perl 0.17-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatmandu-xml-perl 0.17-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-xml-perl 0.17-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms