jcwren has asked for the wisdom of the Perl Monks concerning the following question:
Thanks to ase (who I can't put in brackets, I get a server error), I've been playing with the HTML::TableExtract module. This is a really slick little module for extracting table data from HTML pages. However, it has a minor drawback for what I'm trying to do. If there is any HTML data between the <TD> and </TD> tags, it gets stripped. I would like it to return the HTML between the tags, and I've figured out how to do that. Unfortunately, I can't figure out how to access the data I've stored. Below is a model of what's happening:
The _add_text() that I provide needs to access the data I've stored in the jcwExtract module. If I can either figure out how to access the parent's parent data (HTML::TableExtract::TableState -> HTML::TableExtract -> ->jcwExtract), I can do this, but it feels unclean. I'd rather figure out how to subclass the HTML::TableExtract::TableState module and override the _add_text() method.
I would post the code, but it's a little lengthy, so instead, here's a link to it. It's difficult to boil down to a short test case, but I'll try to add some more to it in a bit. I'll be happy to try any suggestions anyone has as to how to pull this off...
--Chris
- HTML::TableExtract is a sub-class of HTML::Parser.
- jcwExtract is a sub-class of HTML::TableExtract.
- jcwExtract overrides the start() method of HTML::TableExtract, and successfully pulls the data I want, storing it in a private hash (the classic $self->{sometag} = thatdata)
- HTML::Extract has an internal package called HTML::TableExtract::TableState.
- HTML::TableExtract::TableState has a method called _add_text(), that adds the text found in the table to a 'TableState object'
The _add_text() that I provide needs to access the data I've stored in the jcwExtract module. If I can either figure out how to access the parent's parent data (HTML::TableExtract::TableState -> HTML::TableExtract -> ->jcwExtract), I can do this, but it feels unclean. I'd rather figure out how to subclass the HTML::TableExtract::TableState module and override the _add_text() method.
I would post the code, but it's a little lengthy, so instead, here's a link to it. It's difficult to boil down to a short test case, but I'll try to add some more to it in a bit. I'll be happy to try any suggestions anyone has as to how to pull this off...
--Chris
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Life in the land of OOP
by merlyn (Sage) on Aug 02, 2000 at 18:14 UTC | |
by jcwren (Prior) on Aug 03, 2000 at 07:24 UTC | |
Re: Life in the land of OOP
by eak (Monk) on Aug 02, 2000 at 20:18 UTC | |
Re: Life in the land of OOP
by ase (Monk) on Aug 03, 2000 at 13:44 UTC | |
Re: Life in the land of OOP, and I'm confused.
by mojotoad (Monsignor) on Nov 07, 2002 at 16:22 UTC |
Back to
Seekers of Perl Wisdom