1XML::LibXML::AttributeHUassehr(3C)ontributed Perl DocumeXnMtLa:t:iLoinbXML::AttributeHash(3)
2
3
4

NAME

6       XML::LibXML::AttributeHash - tie an XML::LibXML::Element to a hash to
7       access its attributes
8

SYNOPSIS

10        tie my %hash, 'XML::LibXML::AttributeHash', $element;
11        $hash{'href'} = 'http://example.com/';
12        print $element->getAttribute('href') . "\n";
13

DESCRIPTION

15       This class allows an element's attributes to be accessed as if they
16       were a plain old Perl hash. Attribute names become hash keys.
17       Namespaced attributes are keyed using Clark notation.
18
19        my $XLINK = 'http://www.w3.org/1999/xlink';
20        tie my %hash, 'XML::LibXML::AttributeHash', $element;
21        $hash{"{$XLINK}href"} = 'http://localhost/';
22        print $element->getAttributeNS($XLINK, 'href') . "\n";
23
24       There is rarely any need to use XML::LibXML::AttributeHash directly. In
25       general, it is possible to take advantage of XML::LibXML::Element's
26       overloading. The example in the SYNOPSIS could have been written:
27
28        $element->{'href'} = 'http://example.com/';
29        print $element->getAttribute('href') . "\n";
30
31       The tie interface allows the passing of additional arguments to
32       XML::LibXML::AttributeHash:
33
34        tie my %hash, 'XML::LibXML::AttributeHash', $element, %args;
35
36       Currently only one argument is supported, the boolean "weaken" which
37       (if true) indicates that the tied object's reference to the element
38       should be a weak reference. This is used by XML::LibXML::Element's
39       overloading. The "weaken" argument is ignored if you don't have a
40       working Scalar::Util::weaken.
41
42
43
44perl v5.34.0                      2021-07-23     XML::LibXML::AttributeHash(3)
Impressum