--Snipped the previous posts as well as some of the redundant bits from below.--
>Hello Webley. See my comments below. >>snip >They are very different: > > my $root = HTML::TreeBuilder->new_from_content($content) > >is the same as > > my $root = HTML::TreeBuilder->new; > $root->parse($content); > $root->eof; > >and without parsing some sort of HTML to start with you are working with >an empty HTML tree. >>snip > >Unless you have parsed some HTML here your look_down will find nothing! I was opening the file and passing it for parsing in separate steps like this: open IN, "$html_file" || die "Can't open input: $!"; my $root = HTML::TreeBuilder->new; $root->parse_file(*IN); I have now replaced those lines with these: open IN, "$html_file" || die "Can't open input: $!"; my $root = HTML::TreeBuilder->new_from_file(*IN); >Here is your problem. starttag and endtag return *strings*, and you are >passing > > "<td class="fmdata">$recs[$i]</td>" > >to the push_content method. That is a single text element and you are >losing the <td> element that should contain the text value in $recs[$i]. > >Write this instead > > sub create_detail_row { > > my $data = shift; > > my $tr = HTML::Element->new('tr'); > > foreach my $text (@$data) { > my $td = HTML::Element->new('td', class => 'fmdata'); > $td->push_content($text); > $tr->push_content($td); > } > > return $tr; > } Excellent. This works great. The code is cleaner too. >>snip >> Since the detail rows are where the problem lies, maybe that's the >> spot I need to check? The >> $row->push_content($cell->starttag().$recs[$i].$cell->endtag()); >> part? I was thinking that by the time I get to the print OUT >> $root->as_HTML part, everything should be good to go, but alas that >> is not the case. > >Indeed. I hope you understand why now? I do. Thanks for the explanation. >>snip > >Once your HTML tree is built, you need to write > > print OUT $root->as_HTML('<>&', ' '); > >and all should be well. > >Cheers, > >Rob Hi, Rob - Thanks very much for taking the time to explain how this should work. I really appreciate your help. Regards, Webley -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/