Element Class

Used to represent a DOM element in an HTML document.

Constructors

Element( String outerHTML )

Public Methods

getName( ) returns String
Returns the node name associated with the element
getAttributes( ) returns String
Returns the element attributes
isClosed( ) returns boolean
Returns true if the element has a closing tag or is self closing
getInnerHTML( ) returns String
Returns the HTML content (inner HTML) of an element as a String.
getOuterHTML( ) returns String
Returns the HTML used to define this element (tag and attributes), as well as the HTML content (inner HTML). You can use this String to remove or replace elements from the original HTML document.
getInnerText( ) returns String
Removes all HTML tags and attributes inside this element, leaving the raw rendered text.
getAttribute( String attributeName ) returns String
Returns the value for a given attribute. If no match is found, returns an empty string.
getElementByID( String id ) returns Element
Returns an HTML Element with given a id. Returns null if the element was not found.
getElementsByTagName( String tagName ) returns Element[]
Returns an array of HTML Elements with given tag name.
getElementByTagName( String tagName ) returns Element
Returns the first HTML Element with given tag name. Returns null if an element was not found.
getChildNodes( ) returns Element[]
getElements( String tagName, String attributeName, String attributeValue ) returns Element[]
Returns an array of HTML Elements with given tag name, attribute, and attribute value (e.g. "div", "class", "panel-header").
getElementByAttributes( String tagName, String attributeName, String attributeValue ) returns Element
Returns the first HTML Element with given tag name and attribute. Returns null if an element was not found.
getImageLinks( ) returns String[]
Returns a list of links to images. The links may include relative paths. Use the Parser.getAbsolutePath() method to resolve the relative paths to a fully qualified url.
toString( ) returns String
Returns the outer HTML of this element. See getOuterHTML() for more information.
stripHTMLTags( ) returns String
getAttributeValue( String attributeName ) returns String