Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
XML::LibXML::AttributeUser(Contributed Perl DocumXML::LibXML::AttributeHash(3)

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

	tie my %hash, 'XML::LibXML::AttributeHash', $element;
	$hash{'href'} =	'';
	print $element->getAttribute('href') . "\n";

       This class allows an element's attributes to be accessed	as if they
       were a plain old	Perl hash. Attribute names become hash keys.
       Namespaced attributes are keyed using Clark notation.

	my $XLINK = '';
	tie my %hash, 'XML::LibXML::AttributeHash', $element;
	$hash{"{$XLINK}href"} =	'http://localhost/';
	print $element->getAttributeNS($XLINK, 'href') . "\n";

       There is	rarely any need	to use XML::LibXML::AttributeHash directly. In
       general,	it is possible to take advantage of XML::LibXML::Element's
       overloading. The	example	in the SYNOPSIS	could have been	written:

	$element->{'href'} = '';
	print $element->getAttribute('href') . "\n";

       The tie interface allows	the passing of additional arguments to

	tie my %hash, 'XML::LibXML::AttributeHash', $element, %args;

       Currently only one argument is supported, the boolean "weaken" which
       (if true) indicates that	the tied object's reference to the element
       should be a weak	reference. This	is used	by XML::LibXML::Element's
       overloading. The	"weaken" argument is ignored if	you don't have a
       working Scalar::Util::weaken.

perl v5.32.0			  2020-05-08	 XML::LibXML::AttributeHash(3)


Want to link to this manual page? Use this URL:

home | help