]>
Commit | Line | Data |
---|---|---|
ce4e9192 TB |
1 | #!/usr/bin/perl -T |
2 | ||
3 | ||
4 | use warnings; | |
5 | use strict; | |
6 | ||
7 | use Test::More; | |
8 | use Test::XML; | |
9 | ||
10 | BEGIN { | |
11 | use_ok('HTML::TreeBuilder'); | |
12 | use_ok('HTML::Element::Prune'); | |
13 | } | |
14 | ||
15 | ||
16 | ||
17 | my $root = HTML::TreeBuilder->new(); | |
18 | my $html =<<'EOHTML'; | |
19 | <html> | |
20 | <head> | |
21 | <title></title> | |
22 | </head> | |
23 | <body> | |
24 | <div>There was man named Jed</div> | |
25 | <div>He did not have a head</div> | |
26 | <div>He lived beneath a sled</div> | |
27 | <div>Now he's afraid of Fred...</div> | |
28 | <div> | |
29 | </div> | |
30 | </body> | |
31 | </html> | |
32 | EOHTML | |
33 | ||
34 | $root->parse($html); | |
35 | $root->delete_ignorable_whitespace; | |
36 | $root->prune; | |
37 | ||
38 | my $expected = ' | |
39 | <html> | |
40 | <body> | |
41 | <div>There was man named Jed</div><div>He did not have a head</div><div>He lived beneath a sled</div><div>Now he's afraid of Fred...</div> </body> | |
42 | </html> | |
43 | '; | |
44 | ||
45 | #warn sprintf 'HTML:%s:HTML', $root->as_HTML; | |
46 | ||
47 | is_xml($root->as_HTML, $expected, 'test pruning'); | |
48 | ||
49 | ||
50 | ||
51 | done_testing; |