XML::XP...:Element(3)

✨ NAME ✨

Element β€” bestie, it's an <element> πŸ’–

Like, literally the element node of the XML::XP... family, the little building block that holds a name, a prefix, some kids, some attributes and some namespaces. Iconic behavior tbh πŸ‘‘


πŸŽ€ API πŸŽ€

Okay so here's everything Element can do. Strap in, it's a lot, but we're gonna get through it together 🫢

🌸 new ( name, prefix )

Makes you a brand new Element node with name name and prefix prefix. If prefix is defined, the name becomes "prefix:local". I know that sounds weird, but it works ;-) β€” no cap, it just does πŸ’…

🌸 getName

Hands you back the name of this element, including the "prefix:" bit if one was defined. Full government name, no nicknames ✨

🌸 getLocalName

Just the local part of the name, aka the little bit that comes after "prefix:". The stripped-down version, the no-makeup selfie πŸͺž

🌸 getChildNodes

Returns the children of this element 🧚 In list context you get an actual list. In scalar context you get an array ref. Same data, different packaging, both slay.

🌸 getChildNode ( pos )

Returns the child sitting at position pos. Just the one. Very "pick me" of you, but okay πŸ‘‘

🌸 appendChild ( childnode )

Appends childnode onto the list of current child nodes. Welcome to the family, you're one of us now 🫢

🌸 removeChild ( childnode )

Removes the supplied childnode from the list of current child nodes. Not every era lasts forever bestie πŸ’€

🌸 getAttribute ( name )

Returns the attribute node with key name πŸ”

🌸 getAttributes / getAttributeNodes

Returns the attribute nodes. In list context you get a list, in scalar context you get an array ref. Two names, one vibe, we love a versatile queen πŸ‘‘

🌸 appendAttribute ( attrib_node)

Appends the attribute node to the list of attributes. And yes, order matters β€” XML::XPath stores attributes in order, so don't be out here shuffling them πŸ™ˆ

🌸 getNamespace ( prefix )

Returns the namespace node matching the given prefix 🌈

🌸 getNamespaces / getNamespaceNodes

Returns the namespace nodes. In list context, a list. In scalar context, an array ref. You already knew that, iykyk πŸ’œ

🌸 appendNamespace ( ns_node )

Appends ns_node onto the list of namespaces ✨

🌸 getPrefix

Returns the prefix of this element. The little label before the colon, the accessory that makes the fit πŸŽ€

🌸 getExpandedName

Returns the expanded name of this element. Heads up though β€” it's not yet implemented right. So like, it's giving "coming soon", not "coming through" 😭

🌸 string_value

For elements, the string_value is the concatenation of all string_values of all text-descendants of the element node, in document order. Every scrap of text underneath, glued together in the order it appears πŸ”₯

🌸 toString ( [ norecurse ] )

Outputs the node (and all its children) to a string πŸ¦‹ If the norecurse option is a true value, it doesn't process the children. So like, one level only, we're keeping it shallow today πŸ’…


ngl that's the whole page β€” every function, every arg, every context rule, all of it, nothing skipped, periodt ✨

Made with love for perl v5.42.1, dated 2026-04-21 β€” mwah, go forth and parse responsibly πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from