in reply to HTML and Xpath
#!/usr/bin/perl -- use strict; use warnings; use HTML::TreeBuilder::XPath; my $tree = HTML::TreeBuilder::XPath->new; $tree->parse_content(<<'__HTML__'); <html> <body> <div> <div class="here">this's the value</div> </div> <div> <div class="here">this's the value</div> </div> <div> <div class="here">this's the value</div> </div> <div> <div class="here">this's the value</div> </div> <div> <div class="here">this's the value</div> </div> <div> <div class="here">this's the value</div> </div> </body> </html> __HTML__ for my $result ($tree->findnodes(q{/html/body/div})) { print "$result ", $result->detach(),"\n<br>\n"; print $result->findvalue(q{//div[@class="here"]}); print "\n<br>\n\n"; } __END__ HTML::Element=HASH(0x1b7897c) HTML::Element=HASH(0x1b787e4) <br> this's the value <br> HTML::Element=HASH(0x1b78a48) HTML::Element=HASH(0x1b787e4) <br> this's the value <br> HTML::Element=HASH(0x1b78afc) HTML::Element=HASH(0x1b787e4) <br> this's the value <br> HTML::Element=HASH(0x1b78bb0) HTML::Element=HASH(0x1b787e4) <br> this's the value <br> HTML::Element=HASH(0x1b78c64) HTML::Element=HASH(0x1b787e4) <br> this's the value <br> HTML::Element=HASH(0x1b78d18) HTML::Element=HASH(0x1b787e4) <br> this's the value <br>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML and Xpath
by Anonymous Monk on Nov 06, 2008 at 15:09 UTC | |
by way (Sexton) on Nov 06, 2008 at 15:56 UTC | |
|
Re^2: HTML and Xpath
by Anonymous Monk on Aug 17, 2009 at 11:10 UTC | |
|
Re^2: HTML and Xpath
by way (Sexton) on Nov 06, 2008 at 15:53 UTC |