HTML::DOM::Node - A Perl class for representing the nodes of an HTML DOM tree
use HTML::DOM::Node ':all'; # constants use HTML::DOM; $doc = HTML::DOM->new; $doc->isa('HTML::DOM::Node'); # true $doc->nodeType == DOCUMENT_NODE; # true $doc->firstChild; $doc->childNodes; # etc
This is the base class for all nodes in an HTML::DOM tree. (See "CLASSES AND DOM INTERFACES" in HTML::DOM.) It implements the Node and EventTarget DOM interfaces.
The following DOM attributes are supported:
These two are implemented not by HTML::DOM::Node itself, but by its subclasses.
There is also a _set_ownerDocument method, which you probably do not need to know about.
_set_ownerDocument
See the DOM spec. for descriptions of most of these.
The $listener should be either a coderef or an object with a handleEvent method. (HTML::DOM does not implement any such object since it would just be a wrapper around a coderef anyway, but has support for them.) An object with &{} overloading will also do.
$listener
handleEvent
&{}
$capture is a boolean indicating whether this is to be triggered during the 'capture' phase.
$capture
The $listener should be the same reference passed to addEventListener.
addEventListener
This is not a DOM method (hence the underscores in the name). It returns a list of all event listeners for the given event name. $capture is a boolean that indicates which list to return, either 'capture' listeners or normal ones.
$event_object is an object returned by HTML::DOM's createEvent method, or any object that implements the interface document in HTML::DOM::Event.
createEvent
dispatchEvent does not automatically call the handler passed to the document's default_event_handler. It is expected that the code that calls this method will do that (see also "trigger_event").
dispatchEvent
default_event_handler
The return value is a boolean indicating whether the default action should be taken (i.e., whether preventDefault was not called).
Here is another non-DOM method. $event can be an event object or simply an event name. This method triggers an event for real, first calling dispatchEvent and then running the default action for the event unless an event listener cancels it.
$event
These two (non-DOM) methods of HTML::Element are overridden, so that they work correctly with comment and text nodes.
The following node type constants are exportable:
HTML::DOM
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.