HTML::DOM::Element - A Perl class for representing elements in an HTML DOM tree
use HTML::DOM; $doc = HTML::DOM->new; $elem = $doc->createElement('a'); $elem->setAttribute('href', 'http://www.perl.org/'); $elem->getAttribute('href'); $elem->tagName; # etc
This class represents elements in an HTML::DOM tree. It is the base class for other element classes (see "CLASSES AND DOM INTERFACES" in HTML::DOM.) It implements the Element and HTMLElement DOM interfaces.
You should normally use HTML::DOM's createElement method. This is listed here only for completeness:
createElement
$elem = new HTML::DOM::Element $tag_name;
$elem will automatically be blessed into the appropriate class for $tag_name.
$elem
$tag_name
The following DOM attributes are supported:
Returns the tag name.
These five get (optionally set) the corresponding HTML attributes. Note that className corresponds to the class attribute.
className
class
This returns a CSS::DOM::Style object, representing the contents of the 'style' HTML attribute.
And there is also the following non-DOM attribute:
This contains the offset (in characters) within the HTML source of the element’s first child node, if it is a text node. This is set (indirectly) by HTML::DOM’s write method. You can also set it yourself.
write
Returns the attribute's value as a string.
Sets the attribute named $name to $value.
$name
$value
Deletes the $named attribute.
Returns an attribute node (HTML::DOM::Attr).
Sets the attribute whose name is $attr->nodeName to the attribute object itself. If it replaces another attribute object, the latter is returned.
$attr->nodeName
Removes and returns the $attr.
$attr
This finds all elements with that tag name under the current element, returning them as a list in list context or a node list object in scalar context.
Returns true or false, indicating whether this element has an attribute named $name, even one that is implied.
This triggers a click event on the element; nothing more.
This overrides HTML::DOM::Node's method to trigger a DOMActivate event after a click.
HTML::DOM
HTML::DOM::Node
HTML::Element
All the HTML::Element subclasses listed under "CLASSES AND DOM INTERFACES" in HTML::DOM
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'element’s'. Assuming UTF-8
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.