I don't see anything before my use of getElementByClassName that would have put us in the context of that subclassI do ;-) In your first example you have:
@elem now contains a list of HTML::TagParser::Element objectsmy $html = HTML::TagParser->new($line); my @elem = $html->getElementsByClassName($class);
Here $body is a single HTML::TagParser::Element object, and you can't call getElementsByClassName on that object. Try this (untested):my $html = HTML::TagParser->new($line); my $body = $html->getElementById($id); my @elem = $body->getElementsByClassName($class);
my $html = HTML::TagParser->new($line); my $body = $html->getElementById($id); $body = $body->subTree(); # $body is now a new HTML::TagParser object my @elem = $body->getElementsByClassName($class);
In reply to Re: Can't locate object method "getElementsByClassName" via package "HTML::TagParser::Element"
by tangent
in thread Can't locate object method "getElementsByClassName" via package "HTML::TagParser::Element"
by Vonunov
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |