public interface HtmlElement
WebBot
. As
an example, consider this HTML fragment:
<img src="logo.jpg" width="100" height="50"/>
When parsed by a WebBot
, this HTML would be converted to a single
HtmlElement object. That object's "type" would be "img". It would
have three attributes: "src", "width", and "height". Each of these
attributes could be retrieved using getAttributeValue(String)
.
In this case, there would be no text value associated with the tag,
since it has no children (in a DOM sense). As another example,
consider this second HTML fragment:
<a href="http://www.vt.edu/">Virginia Tech</a>
When parsed by a WebBot
, this HTML would be converted to a single
HtmlElement object as well. That object's type would be "a". It would
have one attribute: "href". If you called its
getText()
method, you would get "Virginia Tech".
Modifier and Type | Method and Description |
---|---|
Iterable<String> |
getAttributes()
Get an Iterable that will allow you to cycle through the complete set
of attributes on this element.
|
String |
getAttributeValue(String attributeName)
Look up an attribute's value on this element.
|
String |
getInnerHTML()
Get the entire nested HTML content surrounded by this element,
including any nested HTML elements with full markup.
|
String |
getText()
Get the text contained by this element, without any embedded
HTML tags.
|
String |
getType()
Get the "type" of this element--that is, the HTML name of the tag,
such as "a", "h1", "img", etc.
|
boolean |
hasAttribute(String attributeName)
Check to see if this element has a specific attribute.
|
String |
toString()
Generate a complete HTML rendering of this element, all its attributes,
and any text that it contains.
|
String getType()
String getText()
String getInnerHTML()
boolean hasAttribute(String attributeName)
attributeName
- The attribute to check forString getAttributeValue(String attributeName)
attributeName
- The attribute to look upIterable<String> getAttributes()