Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use Modern::Perl;
  4. use Mojo::DOM;
  5.  
  6. my $dom = Mojo::DOM->new('<html><div><div class="somediv"><ul><li><a href="http://one">one</a>ID1</li><li><a href="http://two">two</a>ID2</li><li><a href="http://three">three</a>ID3</li></ul></div></div></html>');
  7. foreach my $li ($dom->find('div[class=somediv] > ul')->children) {
  8. say $li;
  9. say '-------------';
  10. }
  11.  
  12.  
  13.  
  14. output:
  15. debian-min /fs/data/Documents/Dropbox/Dev/perl/li # ./test.pl
  16. <li><a href="http://one">one</a>ID1</li>
  17. <li><a href="http://two">two</a>ID2</li>
  18. <li><a href="http://three">three</a>ID3</li>
  19. -------------
  20.  
  21.  
  22.  
  23. expected output:
  24. debian-min /fs/data/Documents/Dropbox/Dev/perl/li # ./test.pl
  25. <li><a href="http://one">one</a>ID1</li>
  26. -------------
  27. <li><a href="http://two">two</a>ID2</li>
  28. -------------
  29. <li><a href="http://three">three</a>ID3</li>
  30. -------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement