The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::DOM::Element - A Perl class for representing elements in an HTML DOM tree

SYNOPSIS

  use HTML::DOM;
  $doc = HTML::DOM->new;
  $elem = $doc->createElement('a');

  $elem->setAttribute('href', 'http://www.perl.org/');
  $elem->getAttribute('href');
  $elem->tagName;
  # etc

DESCRIPTION

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.

METHODS

Constructor

You should normally use HTML::DOM's createElement method. This is listed here only for completeness:

  $elem = new HTML::DOM::Element $tag_name;

$elem will automatically be blessed into the appropriate class for $tag_name.

Attributes

The following DOM attributes are supported:

tagName

Returns the tag name.

id
title
lang
dir
className

These five get (optionally set) the corresponding HTML attributes. Note that className corresponds to the class attribute.

style

This returns a CSS::DOM::StyleDecl object, representing the contents of the 'style' HTML attribute.

And there is also the following non-DOM attribute:

content_offset

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.

Other Methods

See the DOM spec. for descriptions.

getAttribute
setAttribute
removeAttribute
getAttributeNode
setAttributeNode
removeAttributeNode
getElementsByTagName
hasAttribute

SEE ALSO

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:

Around line 219:

Non-ASCII character seen before =encoding in 'element’s'. Assuming UTF-8