Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Trouble Parsing HTML

by nerfherder (Monk)
on Jan 28, 2005 at 22:47 UTC ( [id://426150]=note: print w/replies, xml ) Need Help??


in reply to Trouble Parsing HTML

TMTOWTDI, that's for sure! :-)
#!/usr/bin/perl -w use strict; use HTML::TokeParser; my $p = HTML::TokeParser->new( *DATA ); for (my $token = $p->get_tag("select")) { my $select = $token->[1]{name} ; print "$select\n"; } while (my $token2 = $p->get_tag("option")) { if ($token2->[1]{selected}) { my $option = $p->get_text("option"); print "$option\n"; } } __DATA__ <select name="cmbPurpose" id="cmbPurpose" tabindex="3"> <option value="CD">Cell Development</option> <option value="MS">Miscellaneous R&amp;D</option> <option value="NP">New Package</option> <option value="NR">Non R&amp;D</option> <option value="PC">New process</option> <option selected="selected" value="PD">New product</option> <option value="SP">Sustaining Product</option> <option value="SW">Software and Platform</option> <option value="TD">Technology Development</option>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://426150]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-24 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found