#!/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>
In reply to Re: HTML and Xpath
by Anonymous Monk
in thread HTML and Xpath
by way
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |