in reply to How to obtain text in Mojo::DOM ?
#!/usr/bin/perl use Mojo::DOM; my $dom = Mojo::DOM->new(); $|=1; $text=' <a class="ab">2016-05-18</a> <a class="a b">2016-05-19</a> <a class="b">2016-05-20</a> <a class="a">2016-05-21</a> '; my $test1=$dom->parse($text)->at('a.ab')->text; print "18: $test1\n"; my @test2=$dom->parse($text)->find('a.a b')->map('text')->each; print "19: @test2 (bad)\n"; my $test3=$dom->parse($text)->at('a.a.b')->text; print "19: $test3\n";
18: 2016-05-18 19: 2016-05-18 2016-05-19 2016-05-20 2016-05-21 (bad) 19: 2016-05-19
Note, the find('a.a b') does not match anything, so to make it more interesting, I did a find('a. a b')
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to obtain text in Mojo::DOM ?
by Perl_Love (Acolyte) on May 22, 2016 at 12:04 UTC | |
by Anonymous Monk on May 22, 2016 at 12:10 UTC |