--- "Thurn, Martin" <[EMAIL PROTECTED]> wrote: > I ran into similar problems for my module WWW::Search. > No, out-of-the-box you can not re-use an HTML::TreeBuilder object to parse > a new file. BUT you can use the following code as a "reset". I.e. call > parse, muck with the tree, do the following four lines, and call parse > again. This does the same as new() but without changing the store_comments, > store_pis settings, etc: > > $self->{'_head'} = $self->insert_element('head',1); > $self->{'_pos'} = undef; # pull it back up > $self->{'_body'} = $self->insert_element('body',1); > $self->{'_pos'} = undef; # pull it back up again
i will look into how that can be added to $tree later. but a reset method from HTML::TreeBuilder would be nice. > The reason you can't re-use your HTML::Element is because it's a > reference, and when the tree gets deleted, your Element gets deleted right > along with it. > > - - Martin Thurn > just found that $h->clone can get around this. too bad i can't do the same to a tree before it parses the file. from HTML::Element, You are free to clone HTML::TreeBuilder trees, just as long as: 1) they're done being parsed, or 2) you don't expect to resume parsing into the clone. (You can continue parsing into the original; it is never affected.) just to make sure, (english isn't my first language) does it say that i can't clone a tree if it doesn't parse something? Qiang __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com