-
-
03 Feb 2018 06:12:46 UTC
- Distribution: HTML-DOM
- Module version: 0.058
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (4)
- Testers (704 / 72 / 3)
- Kwalitee
Bus factor: 0- 70.64% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (197.99KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Father Chrysostomos <sprout & cpan . org>
- Dependencies
- CSS::DOM
- CSS::DOM::Style
- CSS::DOM::StyleSheetList
- Carp
- Date::Format
- Exporter
- HTML::Encoding
- HTML::Parser
- HTML::Tagset
- HTTP::Headers
- HTTP::Headers::Util
- HTTP::Message
- HTTP::Request
- HTTP::Request::Common
- HTTP::Response
- Scalar::Util
- Test::More
- URI
- constant
- overload
- strict
- utf8
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
HTML::DOM::Element::Form - A Perl class for representing 'form' elements in an HTML DOM tree
VERSION
Version 0.058
SYNOPSIS
use HTML::DOM; $doc = HTML::DOM->new; $elem = $doc->createElement('form'); $elem->method('GET') # set attribute $elem->method; # get attribute $elem->enctype; $elem->tagName; # etc
DESCRIPTION
This class implements 'form' elements in an HTML::DOM tree. It implements the HTMLFormElement DOM interface and inherits from HTML::DOM::Element (q.v.).
A form object can be used as a hash or an array, to access its input fields, so
$form->[0]
and$form->{name}
are shorthand for$form->elements->[0]
and$form->elements->{name}
, respectively.This class also tries to mimic HTML::Form, but is not entirely compatible with its interface. See "WWW::Mechanize COMPATIBILITY", below.
DOM METHODS
In addition to those inherited from HTML::DOM::Element and HTML::DOM::Node, this class implements the following DOM methods:
- elements
-
Returns a collection (HTML::DOM::Collection::Elements object) in scalar context, or a list in list context, of all the input fields this form contains. This differs slightly from the
inputs
method (part of the HTML::Form interface) in that it includes 'button' elements, whereasinputs
does not (though it does include 'input' elements with 'button' for the type). - length
-
Same as
$form->elements->length
. - name
- acceptCharset
- action
- enctype
- method
- target
-
Each of these returns the corresponding HTML attribute (
acceptCharset
corresponds to the 'accept-charset' attribute). If you pass an argument, it will become the new value of the attribute, and the old value will be returned. - submit
-
This triggers the form's 'submit' event, calling the default event handler (see "EVENT HANDLING" in HTML::DOM). It is up to the default event handler to take any further action. The form's
make_request
method may come in handy.This method is actually just short for $form->trigger_event('submit'). (See HTML::DOM::EventTarget.)
- reset
-
This triggers the form's 'reset' event.
- trigger_event
-
This class overrides the superclasses' method to trigger the default event handler for form submissions, when the submit event occurs, and reset the form when a reset event occurs.
WWW::Mechanize COMPATIBILITY
In order to work with WWW::Mechanize, this module mimics, and is partly compatible with the interface of, HTML::Form.
HTML::Form's class methods do not apply. If you call
HTML::DOM::Element::Form->parse
, for instance, you'll just get an error, because it doesn't exist.The
dump
andtry_others
methods do not exist either.The
click
method behaves differently from HTML::Form's, in that it does not callmake_request
, but triggers a 'click' event if there is a button to click, or a 'submit' event otherwise.The
method
,action
,enctype
,attr
,inputs
,find_input
,value
,param
,make_request
andform
methods should work as expected.SEE ALSO
Module Install Instructions
To install HTML::DOM, copy and paste the appropriate command in to your terminal.
cpanm HTML::DOM
perl -MCPAN -e shell install HTML::DOM
For more information on module installation, please visit the detailed CPAN module installation guide.