in reply to Re: HTML parsing OR capturing text from a string within tags
in thread HTML parsing OR capturing text from a string within tags
My print statements showed me that there is a library of predefined tags. If I can add my own tags, I think it will work :) I will also try your method. Tackling this is sort of fun. some output:sub find_by_ktag_name { my(@pile) = shift(@_); # start out the to-do stack for the traverser Carp::croak "find_by_created_tag_name can be called only as an objec +t method" unless ref $pile[0]; return() unless @_; print "pile is @pile\n"; my(@tags) = $pile[0]->_fold_case(@_); print "tags are @tags\n"; my(@matching, $this, $this_tag); while(@pile) { $this_tag = ($this = shift @pile)->{'_tag'}; print "In while loop. this_tag is $this_tag\n"; foreach my $t (@tags) { print "foreach going through elements of tag. Elements are t an +d t is $t\n"; print "next step will check to see if t is eq to this_tag. this_ +tag is $this_tag\n"; if($t eq $this_tag) { print "inside of if... t and this_tag are equal.\n"; if(wantarray) { print "I am here if wantarray is true. Now push this onto +array matching\n"; push @matching, $this; print "matching is @matching\n"; last; } else { print "wantarray not true, returning this $this\n"; return $this; } } } unshift @pile, grep ref($_), @{$this->{'_content'} || next}; } print "returning @matching if wantarray\n"; return @matching if wantarray; return; }
next step will check to see if t is eq to this_tag. this_tag is a In while loop. this_tag is a next step will check to see if t is eq to this_tag. this_tag is font next step will check to see if t is eq to this_tag. this_tag is br
|
|---|