HTML::DOM::Element::Select - A Perl class for representing 'select' elements in an HTML DOM tree
Version 0.054
use HTML::DOM; $doc = HTML::DOM->new; $elem = $doc->createElement('select'); $elem->focus(); $elem->blur(); # $elem->add(...) # not yet # $elem->remove(...) # implemented $elem->options; # a list of 'option' elements $elem->name('foo') # set attribute $elem->type; # get attribute $elem->tagName; # etc. $elem->[0]; # first option $elem->[1] = $doc->createElement('option'); $elem->[0] = undef; # deletes it delete $elem->[0]; # same
This class implements 'select' elements in an HTML::DOM tree. It implements the HTMLSelectElement DOM interface and inherits from HTML::DOM::Element (q.v.).
You can use a 'select' element as an array reference, to access the individual elements of its options array. @$elem actually does exactly the same thing as @{$elem->options}. See HTML::DOM::Collection::Options for more info on using the array.
@$elem
@{$elem->options}
In addition to those inherited from HTML::DOM::Element and its superclasses, this class implements the following DOM methods:
Each of these returns the corresponding HTML attribute. If you pass an argument, it will become the new value of the attribute, and the old value will be returned.
Returns the index of the selected option. If there is an argument, it selects the specified option and returns the index of the previous selection.
Returns the number of options.
Returns the form containing this input element.
Returns a list of 'option' elements in list context, or an HTML::DOM::Collection::Options object in scalar context.
Selects the option with the value given if there is an argument and returns the old value, or simply returns the value if there is no argument.
These each trigger the corresponding event.
In addition, the following methods are provided for compatibility with WWW::Mechanize:
This returns an empty list for most input elements, but for checkboxes it returns (undef, $value).
(undef, $value)
An alias to readOnly.
Returns a list of two items: (0) the name of the field and (1) the value.
Same as $elem->checked(1).
$elem->checked(1)
HTML::DOM
HTML::DOM::Collection::Options
HTML::DOM::Element
HTML::DOM::Element::Form
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.