Hello,

I'm using TreeBuilder and am finding it useful.

I have a few questions.

one is if I turn off ingorable_whitespace as such, i get errors when using element methods.

Here is an example:

  sub get_content {
   my $string = shift;
   my $tree = HTML::TreeBuilder->new; # empty tree
   $tree->no_space_compacting(1);
   $tree->ignore_ignorable_whitespace(0);
   $tree->parse($string);
   $tree->eof;
   #$tree->elementify;
   my $content = '';
   $tree = delete_unwanted_nodes($tree);
   my $node = $tree->find_by_tag_name('body');
   #$node = $node->nativize_pre_newlines();
   my @nodes = $node->content_list();
   foreach my $node (@nodes){
   my $cont = $node->as_text(skip_dels => 1);
     if ($cont){
       $content .= $cont;
   }
 }
   $tree = $tree->delete;
   return $content;
}

i get the error: Can't call method "as_text" without a package or object reference at ./test.pl line 152.

which of course goes away if i comment out the ignore_ignorable line.

Also the method nativize_pre_newlines is not implemented, though it is in the docs of HTML::Element. I've written my own simple nativizer. Just wanted to point that out. And I've also written my own as_text_with_newlines, to get around this, but wanted to comment on it.

Thanks for a great set of modules to Gisle and Sean!


Reply via email to