NAME
File::Raw::XML::Attr - an attribute in an XPath result
SYNOPSIS
my @ids = $doc->xpath('//@id');
for my $a (@ids) {
printf "%s=%s on %s\n", $a->name, $a->value, $a->owner->local;
}
DESCRIPTION
What an attribute comes back as when an XPath node-set holds one. An attribute is not a node of the tree, so it is not a File::Raw::XML::Node: it belongs to an element and is named by its position on it. Like a node, it keeps its document alive for as long as it exists.
These are never constructed directly. "find" in File::Raw::XML::XPath and "xpath" in File::Raw::XML::Node return them; "attrs" in File::Raw::XML::Node returns plain arrayrefs instead, which is the cheaper answer when you already have the element.
An attribute holds its element and its position on it, so removing an earlier attribute from that element leaves it naming whatever moved into its place. See "remove_attr" in File::Raw::XML::Node.
METHODS
name
The qualified name as written, so xml:lang rather than lang.
local
The local part of the name.
ns
The namespace URI, or the empty string when the attribute has none. An unprefixed attribute has none, never the default namespace.
prefix
The prefix as written, or the empty string.
value
The value, normalised: as CDATA when nothing declared a type for it, and by the declared type when a document type declaration did.
owner
The File::Raw::XML::Node this attribute is on.
doc
The File::Raw::XML::Document it belongs to.
SEE ALSO
File::Raw::XML::XPath, File::Raw::XML::Namespace, File::Raw::XML::Node.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)