Class ElementCollection
public class ElementCollection
{
// Constructors
public ElementCollection(Element root);
public ElementCollection(Element root, Name tag, int type);
// Methods
public Element getChild(int index);
public int getLength();
public Object item(String name);
public Element item(String name, int index);
}
This class provides a collection interface to elements similar to the element collections found in the Internet Explorer 4.0 Dynamic HTML object model.
public ElementCollection(Element root);
Creates new collection object for given element.
public ElementCollection(Element root, Name tag, int type);
Creates a new collection for iterating over the immediate children of the given root node that have matching tag names and/or element types.
Parameter | Description |
root
| The root to form the collection around.
|
tag
| The name of the tag; this parameter can be null if the name is not important.
|
type
| The element type. Element.ELEMENT is the most common. If the element type is not important, pass -1.
|
public Element getChild(int index);
Retrieves a specified item from the collection by index.
Return Value:
Returns the requested child node; returns null if not found.
Parameter | Description |
index
| The index of the item in the element collection.
|
public int getLength();
Retrieves the number of items in the collection.
Return Value:
Returns the item count.
public Object item(String name);
Retrieves a named item or a collection of matching items.
Return Value:
Returns the requested item. Possible types of objects returned are Element, ElementCollection, or null.
Parameter | Description |
name
| The name of the item or collection of matching items.
|
public Element item(String name, int index);
Retrieves a specified item from the collection of matching items.
Return Value:
Returns the requested item if it is found; returns null if it is not found.
Parameter | Description |
name
| The name of the matching items.
|
index
| The index of the specific matching item to return.
|