XML::LibXML::AttributeHash(3) User Contributed Perl Documentation XML::LibXML::AttributeHash(3)NAME
XML::LibXML::AttributeHash - tie an XML::LibXML::Element to a hash to access its attributes
SYNOPSIS
tie my %hash, 'XML::LibXML::AttributeHash', $element;
$hash{'href'} = 'http://example.com/';
print $element->getAttribute('href') . "
";
DESCRIPTION
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 = 'http://www.w3.org/1999/xlink';
tie my %hash, 'XML::LibXML::AttributeHash', $element;
$hash{"{$XLINK}href"} = 'http://localhost/';
print $element->getAttributeNS($XLINK, 'href') . "
";
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'} = 'http://example.com/';
print $element->getAttribute('href') . "
";
The tie interface allows the passing of additional arguments to XML::LibXML::AttributeHash:
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.16.2 2012-10-22 XML::LibXML::AttributeHash(3)
Check Out this Related Man Page
XML::LibXML::AttributeHash(3) User Contributed Perl Documentation XML::LibXML::AttributeHash(3)NAME
XML::LibXML::AttributeHash - tie an XML::LibXML::Element to a hash to access its attributes
SYNOPSIS
tie my %hash, 'XML::LibXML::AttributeHash', $element;
$hash{'href'} = 'http://example.com/';
print $element->getAttribute('href') . "
";
DESCRIPTION
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 = 'http://www.w3.org/1999/xlink';
tie my %hash, 'XML::LibXML::AttributeHash', $element;
$hash{"{$XLINK}href"} = 'http://localhost/';
print $element->getAttributeNS($XLINK, 'href') . "
";
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'} = 'http://example.com/';
print $element->getAttribute('href') . "
";
The tie interface allows the passing of additional arguments to XML::LibXML::AttributeHash:
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.16.3 2013-05-13 XML::LibXML::AttributeHash(3)
Hi hackers,
I would like to parse the value of one XML tag (e.g. <TAG>).
Following is the script that I have written.
awk -F"" '/<TAG>/,/<\/TAG>/ {
if ( NF == 1 ) {
sub(/^*/,"", $1)
print $1
}
}
Above ascipt works fine for the following XML tag syntax. i.e. prints "Hi" ... (8 Replies)
Hi All,
I am looking for a awk/shell which can find an element named REFERENCE in a XML file and check whether it is empty or not.
If there is no value in the REFERENCE element then correspondingly move the file to some other folder.
The Unix server is AIX version 4.
Any inputs... (9 Replies)
I am modifying someone else's code. There is a foreach statement printing the contents of a hash.
Can someone give me an example of printing the last element in a hash?
The output currently is
A
B
C
D
E
I want the output to be
E (1 Reply)
Any help to extract the root element from an XML file will be appreciated.
Example: test.xml
<?xml version="1.0" encoding="utf-8" ?>
<TestXMLMessage>
<TestRec>
<ID>1000</ID>
</TestRec>
</TestXMLMessage>
Wanted to extract the TestXMLMessage.
Regards,
Chari (6 Replies)
Hi,
I have XML file and I extracted some tags and stored in hash, my data as look like this
$var1={
'stud.xml'={
'24'=>'<address>
<streetname="xxxx"/>
<housenum="138"/">
... (9 Replies)
I want to check if every <Part> element has corresponding <Description> in this sample XML.
....<Lot Of XML>
<Inv lineNumber="2">
<Item>
... (4 Replies)
I am trying to develop a script to replace a lowercase URLs with an upper case URLs in HTM files.
Basically.. replace href="somelowercaseurl" with href="SOMEUPPERCASEURL". In place.
the href's are not located in any specific position in the file.
Here is my shell script :
export... (5 Replies)
Hi folks,
If a declare a direct hash , then the hash element works fine.
my %test = ("test",1);
print %test;
print "\n";
Here in the above, the name of the hash is predeclared...
Suppose now I need to create the hash elements dynamically in the for loop.
$test="hash";
my... (1 Reply)
I am trying to speed up creating a line by line hash file from a huge file using Perl.
Here is my current (working but too slow) Bash code:
(while read line; do hash=$(echo -n $line | md5sum); echo ${hash:0:32}; done)And here is my Perl code:
perl -MDigest::MD5 -le 'foreach $line ( <STDIN> )... (3 Replies)
Hi,
I have a requirement to extract specific element value dynamically from XML message.
Here is the sample message:
<File>
<List>
<main>
<dir>doc/store834/archive</dir>
<count>5</count>
</main>
<main>
<dir>doc/store834/extract</dir>
<count>6</count>
</main>
<main> ... (3 Replies)