perl - obtaining attr names using mojo -
using mojo, how obtain names of attributes? example:
<test a="1" b="2">
i want know there 2 attributes named 'a' , 'b'.
use attr attributes , values:
my $dom = mojo::dom->new('<test a="1" b="2">hello</test>'); $t = $dom->at('test'); # save attributes in hash: $attr_h = $t->attr; "attributes: " . dumper($attr_h); # values 'a' , 'b' "attribute has value " . $t->attr('a'); "attribute b has value " . $t->attr('b'); output:
attributes: $var1 = { 'b' => '2', 'a' => '1' }; attribute has value 1 attribute b has value 2 you can take hash keys array of attributes.
perl mojolicious
No comments:
Post a Comment