in reply to Re^3: Nested div tag
in thread Nested div tag
when i run the below code
#! usr/bin/perl use strict; use warnings; use HTML::TreeBuilder::XPath; my $tree= HTML::TreeBuilder::XPath->new; $tree->parse_file(<<"HTML"); <div class="Row May-2015"> <div class="Cell month-year even"> May-2015 </div> <div class="Cell Release Date even"> 2015-06-25 </div> <div class="Cell National Mortgage Contract Rate even" +> 3.750 </div> </div> HTML my @rows = $tree->findnodes(q{//div[@class= 'Row May-2015']}); #my @rows=$tree->findnodes(q{ //div[ @class =~ /Cell/ ] }); print $#rows; for my $row ( @rows ){ my @cells = $row->findnodes(q{ //div[ @class =~ /Cell/ ] }); for my $cell ( @cells ){ #Dance( $cell ); print $cell; } }
output be like
[ab@linux0059 html_tree_builder]$ perl code.pl -1[ab@linux0059 html_tree_builder]$
It does not take div node
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Nested div tag
by Anonymous Monk on Jul 21, 2016 at 07:07 UTC | |
by perlmad (Sexton) on Jul 21, 2016 at 10:32 UTC | |
by Anonymous Monk on Jul 25, 2016 at 06:24 UTC |