HTML::DOM::Collection::Options - A subclass of HTML::DOM::Collection for 'option' elements
use HTML::DOM; $doc = HTML::DOM->new; $doc->write(' <form name=theform> <select name=choice> <option> <option> </select> </form> '); $doc->close; $options = $doc->forms->{theform}{choice}->options; # returns an HTML::DOM::Collection::Options object $options->[0]; # first option $options->item(0); # same $options-> $elements->{r}; # an array of buttons named 'r' $elements->namedItem('r'); # same () = $elements->namedItem('r'); # list, not array $elements->length; # same as $#$elements
This inherits from HTML::DOM::Collection and adds a few extra methods for compatibility with WWW::Mechanize. This is used to represent a 'select' element's list of options.
Normally you would simply call HTML::DOM::Element::Select's options method (as in the "SYNOPSIS"). But if you wall to call the constructor anyway, here is the syntax:
options
$elements = HTML::DOM::Collection::Options->new($nodelist)
$nodelist should be a node list (HTML::DOM::NodeList) object.
Returns the number of items in the collection.
Returns item number $index, numbered from 0. Note that you call also use $elements->[$index] for short.
$index
$elements->[$index]
Returns the item named $name. You can also write $collection->{$name}.
$name
$collection->{$name}
These last few are provided for WWW::Mechanize compatibility.
Returns the string 'option'.
Returns the name of the 'select' element.
Returns the a list of the options' values. Provided for WWW::Mechanize compatibility.
Selects the option with the value given and returns the old value, or simply returns the value if there is no argument.
Returns true if all the options are disabled, false otherwise.
Returns a list consisting of (0) the name of the 'select' element and (1) the value of the selected option.
The name and form_name_value methods currently die if there are no options.
name
form_name_value
HTML::DOM
HTML::DOM::Collection
HTML::DOM::Element::Select
HTML::DOM::Element::Form
The source of HTML/DOM/Element/Form.pm, where this is implemented.
To install HTML::DOM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::DOM
CPAN shell
perl -MCPAN -e shell install HTML::DOM
For more information on module installation, please visit the detailed CPAN module installation guide.