Re: I'm looking for a form who call "something"

Andrew Davis (Andrew.Davis@jhu.edu)
Tue, 16 May 2000 10:34:16 -0400


Hi Axel,
         Try this:


my $parsed_html = new HTML::TreeBuilder;
$parsed_html->parse($html);
$parsed_html->traverse(\&FindFORM);
exit;

sub FindFORM {
         my ($node, $start, $depth) = @_;
         if (ref $node) {
                 my $tag = $node->tag;
                 if ($tag eq "form") {
                         $thescript=$node->attr('action');
                         print "\n\n\nScript:$thescript\n\n";
                         if (This_is_the_form_you_want) {
                                 $node->traverse(\&ThisRoutineParsesOnlyTheForm);
                         return 0;
                 }
         }
         return 1;                           # yes, recurse
}

sub ThisRoutineParsesOnlyTheForm {
         my ($node, $start, $depth) = @_;
         etc.
}



At 03:53 PM 5/16/00 +0200, you wrote:
>Hi all,
>I parse a html page to extract the form, but i've 2 forms, and I want to keep
>the one who call "something" (I know how it's called)
>
>my @form = HTML::Form->parse($html, $base_uri);
>
>but @form have 2 forms inside...
>
>How to test the good one ?
>
>Thank
>
>Axel R.