in reply to Re^2: Parse html file
in thread Parse html file
I see you have HTML::TreeBuilder installed. This is one way you can use that:
Update: changed slightly to avoid errors
my $tree = HTML::TreeBuilder->new; $tree->parse_file($file); $tree->eof; my @divs = $tree->find_by_attribute('class','formline'); for my $div (@divs) { my $label_div = $div->look_down('class','formlabel') or next; my $label = $label_div->as_text; my $input_div = $div->look_down('class','forminput') or next; my $input = $input_div->as_text; print "$label $input\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Parse html file
by TonyNY (Beadle) on Sep 24, 2018 at 19:08 UTC | |
by tangent (Parson) on Sep 24, 2018 at 19:28 UTC | |
by TonyNY (Beadle) on Sep 25, 2018 at 13:18 UTC | |
by marto (Cardinal) on Sep 25, 2018 at 13:25 UTC |
In Section
Seekers of Perl Wisdom