Catman...er::XML(3pm)

πŸ“¦
version 0.17 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸŽ€ 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