|
CS 1705 Library | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface HtmlElement
This interface represents an instance of some HTML element (or "tag"),
usually obtained by reading from a web page using a 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".
| Method Summary | |
|---|---|
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 |
getText()
Get the text contained by this element. |
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. |
| Method Detail |
|---|
String getType()
String getText()
boolean hasAttribute(String attributeName)
attributeName - The attribute to check for
String getAttributeValue(String attributeName)
attributeName - The attribute to look up
Iterable<String> getAttributes()
String toString()
toString in class Object
|
Last updated: Wed, Apr 1, 2009 12:29 AM EDT | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||