> 
> I am trying to use HTML::TokeParser
> From the cpan page for this I used this example :
>  
>                 while (my $token = $p->get_tag("a")) {
>                         my $url = $token->[1]{href} || "-";
>                         my $text = $p->get_trimmed_text("/a");
>                         print "$url\t$text \n";
>                 }
>  
> Worked great ::
> So I tried to do something similar with the img tag ::
> 
>                 while (my $token = $p->get_tag("img")) {
>                         my $src = $token->[1]{src} || "-";
>                         my $alt = $token->[1]{alt} || "-";
>                         print "$src\t$alt\n";
>                 }
>  
> and I get nothing, even thought I know there are lots of image tags

I tried commenting out the 'a'; version and the 'img' version worked!
So both chunks of code work they just don't work if you run then back to back.
I tried undef $token;
I tried using different names for the tokens ( $token and $tokenq respectively.
I tried removing 'my' from before $token and basically it seems that you can only get 
results from get_tag once.

Is there any way to reset this so that I can do both chunks of code above, 
one after the other, IE call $p->get_tag() more than once?

Thanks

Dan

>  
> Any body know what I could be doing wrong or other wsie how 
> to grab certain attributs form certain tags ? Not sure what 
> the || "-" is for 

duh
|| "-" assigns the value - if it is empty, 

>but it works on the a href attribute 
> http://search.cpan.org/author/GAAS/HTML-Parser-3.27/lib/HTML/T
okeParser.pm
 
Thanks
 
Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to