Hi. The big issue is the ignore unknown tag setting. Also the module does
not like a missing <html> and <body>.
Also this isn't HTML. U might be better served by using XML::Simple.
Printf is ur friend.
use HTML::TreeBuilder;
$html = '<html><body>
<group name="Group1" visible="true" wallpaper="false" toolTipText=""
exposeToVba="notExposed" isReferenceObject="true" linkSize="true"
linkConnections="true" linkAnimations="linkWithoutExpression"
linkBaseObject="System_Bar.Group1">
.....
</button>
</group></body></html>
';
$tree = HTML::TreeBuilder->new();
$tree->ignore_unknown(0);
$tree->warn(1);
$tree->parse($html); $tree->eof;
@Ans = $tree->look_down('_tag' => 'button');
foreach $button (@Ans) {
printf "button is %s\n", $button->attr('name'); # prints "button is
Button1"
printf "button tag is %s\n", $button->tag;
# can also use ${$button}{_tag} prints "button tag is button"
printf "button parent hash pointer is %s\n", $button->parent;
# can also use ${$button}{_parent}
# prints "button parent hash pointer is HTML::Element=HASH(0x1afa5c4)"
foreach $key (keys %{$button->parent}) {
print "key is $key\n";
# prints four keys: _parent, _content, _tag, _implicit
}
printf "button _parent value is %s\n", ${$button}{_parent};
# prints "button _parent value is HTML::Element=HASH(0x1afa5c4)"
printf "button _tag value is %s\n", ${$button}{_tag};
# prints "button _tag value is button"
$parent = $button->parent;
printf "parent tag is %s\n", ${$parent}{_tag};
# prints "parent tag is body"
printf "parent content is %s\n", ${$parent}{_content};
# prints "parent content is ARRAY(0x1afa7b0)"
# foreach $key (@{${$parent}{_content}}) {
# # print "content item is $key";
# }
#print "parent name is " . $parent->attr('name');
$groupid = $button->look_up('_tag', => 'group');
# print "group id is " . $groupid;
}
# $tree->dump;
print $tree->dump; #as_HTML;
button is Button1
button tag is button
button parent hash pointer is HTML::Element=HASH(0x19b9224)
key is _parent
key is visible
key is linkanimations
key is linkbaseobject
key is wallpaper
key is tooltiptext
key is name
key is linksize
key is linkconnections
key is isreferenceobject
key is _content
key is exposetovba
key is _tag
button _parent value is HTML::Element=HASH(0x19b9224)
button _tag value is button
parent tag is group
parent content is ARRAY(0x19b90c8)
button is Button24
button tag is button
button parent hash pointer is HTML::Element=HASH(0x19b9224)
key is _parent
key is visible
key is linkanimations
key is linkbaseobject
key is wallpaper
key is tooltiptext
key is name
key is linksize
key is linkconnections
key is isreferenceobject
key is _content
key is exposetovba
key is _tag
button _parent value is HTML::Element=HASH(0x19b9224)
button _tag value is button
parent tag is group
parent content is ARRAY(0x19b90c8)
--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"
00000100
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs