Catman...ml_read(3pm)

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

πŸ’– Catman...ml_read β€” aka Catmandu::Fix::xml_read πŸ’–

okay bestie, come CLOSE because this one is a Catmandu::Fix from the User Contributed Perl Documentation (that's the 3pm girlies ✨), and she is here to turn your messy little XML strings into MicroXML or simple XML. No cap. πŸ¦‹


✨ NAME ✨

Catmandu::Fix::xml_read β€” parse XML to MicroXML. That's it, that's the whole job, and she eats every time. πŸ’…


🌸 SYNOPSIS 🌸

# parse XML string given in field 'xml'
xml_read(xml)
xml_read(xml, simple: 1)
xml_read(xml, attributes: 0)

Look at her. Three lines. Iconic behavior only. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

So, this Catmandu::Fix literally parses XML strings into MicroXML or simple XML, and she does it with XML::Struct. That's the whole vibe. She takes your XML and makes it make sense. 🫢


🧚 CONFIGURATION 🧚

Vibe check time: the parsing can be configured with the following options of XML::Struct::Reader. Yes, all of them. We're listing every single one, because we don't skip. Periodt. πŸ’…

  • attributes β€” include XML attributes. Enabled by default, so she's already doing this unless you tell her not to. ✨
  • ns β€” define processing of XML namespaces. The default is "keep", so namespaces stay right where they are. πŸŽ€
  • whitespace β€” include ignorable whitespace as text elements. Disabled by default (so by default that whitespace is getting ignored, respectfully). πŸ™ˆ
  • simple β€” convert to a simple key-value structure, as known from XML::Simple. Classic behavior, honestly.
  • root β€” keep (and possibly rename) the root element when converting to "simple" form. She said the root stays, or gets a glow-up name. πŸ‘‘
  • depth β€” only transform to a given depth, and only with the simple option. So like, don't go all the way down, bestie, just to that depth. πŸ¦‹
  • path β€” parse only given elements (and all of its child elements) and return as an array. For instance path => "p" in an XHTML document would return a list of parsed paragraphs (<p>...</p>). Careful, queen: this option overrides option root. 🫢
  • content β€” name of text content when converting to "simple" form. Give that text content a name, she deserves one. 🌸

🌈 SEE ALSO 🌈

Go give these girls a follow, they're all in the same friend group:

  • Catmandu::Fix::xml_write, Catmandu::Fix::xml_simple
  • Catmandu::Fix::xml_transform

k that's the whole page bestie, you're so welcome πŸ’œ

This little manual page is serving perl v5.36.0, dated 2022-09-15, and it's brought to you by the User Contributed Perl Documentation girlies. mwah, drink water, xml_read responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from