tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use HTML::TreeBuilder; use HTML::Element; my $html_bold = <<END; <b><h2> Nested once. <b><h2>Nested twice.</h2></b> Nested once. </h2> </b> END my $tree_bold = HTML::TreeBuilder->new_from_content($html_bold); print "Bold:\n\n"; $tree_bold->dump(); print "\n"; #The last "nested once" is actually not nested at all, as can be seen +from the indenting. #And the nested twice isn't quite right either. # #<html> @0 (IMPLICIT) # <head> @0.0 (IMPLICIT) # <body> @0.1 (IMPLICIT) # <b> @0.1.0 # <h2> @0.1.0.0 # " Nested once. " # <b> @0.1.0.0.1 # <h2> @0.1.0.1 # "Nested twice." # " Nested once. " my $html_font = <<END; <b><font color="red"> Nested once. <b><font color="red"><h2>Nested twice.</font></b> Nested once. </font> </b> END my $tree_font = HTML::TreeBuilder->new_from_content($html_font); print "Font:\n\n"; $tree_font->dump(); print "\n"; #Everything is nested like in the original. #<html> @0 (IMPLICIT) # <head> @0.0 (IMPLICIT) # <body> @0.1 (IMPLICIT) # <b> @0.1.0 # <font color="red"> @0.1.0.0 # " Nested once. " # <b> @0.1.0.0.1 # <font color="red"> @0.1.0.0.1.0 # <h2> @0.1.0.0.1.0.0 # "Nested twice." # " Nested once. " # " "
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::TreeBuilder, nesting with header vs font, different behavior
by jonadab (Parson) on Jun 28, 2005 at 10:54 UTC | |
|
Re: HTML::TreeBuilder, nesting with header vs font, different behavior
by metaperl (Curate) on Jun 29, 2005 at 17:27 UTC |