Interface Element

Element
All Superinterfaces:
Node
All Implemented Interfaces:
Node
All Known Implementing Classes:
HTMLElement, HTMLFormElement, HTMLIFrameElement, HTMLInputElement, HTMLLIElement, HTMLScriptElement, HTMLTableElement, HTMLTableRowElement, f_abstractEntry, f_abstractList, f_additionalInformation, f_box, f_button, f_calendar, f_card, f_cardBox, f_checkButton, f_combo, f_comboGrid, f_component, f_componentsGrid, f_componentsList, f_compositeNumEntry, f_customButton, f_dataGrid, f_dataGridPopup, f_dateChooser, f_dateEntry, f_eventTarget, f_expandBar, f_externalBox, f_fieldSet, f_filtredComponent, f_grid, f_helpButton, f_helpMessageZone, f_hiddenValue, f_hyperLink, f_image, f_imageButton, f_imageCheckButton, f_imageCombo, f_imagePagerButton, f_imageRadioButton, f_imageResetButton, f_imageSubmitButton, f_input, f_itemsList, f_itemsToolFolder, f_keyEntry, f_keyLabel, f_lineBreak, f_list, f_menu, f_menuBar, f_menuBarBase, f_menuBase, f_message, f_messageFieldSet, f_messages, f_numberEntry, f_pager, f_passwordEntry, f_progressBar, f_progressIndicator, f_radioButton, f_resetButton, f_ruler, f_scheduler, f_spinner, f_styledMessage, f_styledText, f_submitButton, f_suggestTextEntry, f_tab, f_tabbedPane, f_text, f_textArea, f_textEditor, f_textEditorCombo, f_textEditorImageButton, f_textEntry, f_timeEntry, f_toolBar, f_toolFolder, f_tree

public Element
extends Node

The Element interface represents an element in an HTML or XML document. Elements may have attributes associated with them; since the Element interface inherits from Node, the generic Node interface attribute attributes may be used to retrieve the set of all attributes for an element. There are methods on the Element interface to retrieve either an Attr object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an Attr object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience.


Field Summary
 String tagName
          The name of the element.
 
Fields inherited from class Node
childNodes, firstChild, lastChild, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, previousSibling
 
Method Summary
 String getAttribute(String name)
          Retrieves an attribute value by name.
 NodeList getElementsByTagName(String name)
          Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
 void removeAttribute(String name)
          Removes an attribute by name.
 void setAttribute(String name, String value)
          Adds a new attribute.
 
Methods inherited from class Node
appendChild, hasChildNodes, insertBefore, removeChild, replaceChild
 

Field Detail

tagName

final String tagName
The name of the element.

Method Detail

getElementsByTagName

NodeList getElementsByTagName(String name)
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.

Parameters:
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching Element nodes.

removeAttribute

void removeAttribute(String name)
Removes an attribute by name. If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.
To remove an attribute by local name and namespace URI, use the removeAttributeNS method.

Parameters:
name - The name of the attribute to remove.

setAttribute

void setAttribute(String name,
                  String value)
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute.
To set an attribute with a qualified name and namespace URI, use the setAttributeNS method.

Parameters:
name - The name of the attribute to create or alter.
value - Value to set in string form.

getAttribute

String getAttribute(String name)
Retrieves an attribute value by name.

Parameters:
name - The name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.