XML::N...LibXML(3pm)

πŸ“¦
version 0.6.0 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

✨ XML::Normalize::LibXML πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation collection, and it's called XML::Normalize::LibXML (3pm, obviously, it's a Perl module, we love a Perl module era). It's the kind of module you reach for when your XML is looking a little ✨messy✨ and you need it to stop having feelings about whitespace. πŸŽ€


πŸ¦‹ NAME πŸ¦‹

XML::Normalize::LibXML β€” simple whitespace striping functions. yes, "striping", that's literally what it says, we're not fixing it, it's iconic. πŸ’…


🌸 SYNOPSIS 🌸

grab the three functions you want, like so:

use XML::Normalize::LibXML qw(trim xml_normalize xml_strip_whitespace);

then it's giving:

$greeting=trim("   hallo world    ");  # returns "hallo world"
xml_normalize($dom->getDocumentElement());
xml_strip_whitespace($dom->getDocumentElement());

see that? trim(" hallo world ") hands you back "hallo world" and the surrounding vibes are just gone. periodt. ✨


πŸ‘‘ DESCRIPTION πŸ‘‘

This module provides simple whitespace striping and text-node normalizing functions. that's the whole job. it does one thing and it does it well, and honestly? main character energy. 🫢

πŸ’– trim($string)

Returns the string with any whitespace occuring at its beginning or end removed. (yes, "occuring" β€” the original said it, we keep it, no cap.) So all that leading and trailing blankness? evicted. 🧹

🌈 xml_normalize($dom)

Puts all Text nodes in the full depth of the sub-tree underneath this Element into a normal form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent Text nodes. Basically no two Text nodes are ever standing awkwardly next to each other at the party β€” only markup is allowed to come between them. 🚧

This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used. so if you're doing XPointer lookups, or literally anything that cares about the exact shape of the tree, this is your girl. πŸ”₯

πŸŽ€ xml_strip_whitespace($dom [,$include_attributes])

Normalizes the subtree and trims whitespace from all Text nodes within the subtree. two-for-one, we love a combo deal. πŸ’…

If the optional argument $include_attributes is defined and non-zero, this function trims whitespace also from all Attribute nodes. so if you want the attributes de-whitespaced too, pass that second argument something defined and non-zero and it'll handle it. otherwise, attributes stay exactly how they are. ⭐

πŸ¦‹ xml_strip_element($node)

Removes leading and trailing whitespace from a given element. single element, in and out, no drama. πŸ’œ


πŸ’œ AUTHOR πŸ’œ

Petr Pajas, pajas@matfyz.cz. legend behaviour, honestly. 🫑


Copyright 2002-2003 Petr Pajas, All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go off, but keep the same terms as Perl itself. iykyk. ✨


πŸ“ SEE ALSO πŸ“

  • XML::LibXML β€” the whole reason any of this works, go say hi. πŸ‘‹

ok so that's the whole page, no skipped parts, no deleted options, every single detail preserved and also slayed. πŸ’€βœ¨

and that's a wrap bestie! πŸŽ€ this page came from perl v5.32.0, dated 2021-01-07, and it lives under the name XML::N...LibXML(3pm) β€” yes the name is literally truncated with dots in the header, that's not me being lazy, that's just how the manpage page title came out. iconic of it. bye!! πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from