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
- fedora 44: perl-XML-XPath 1.49-1.fc44 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms