public class NodeList
extends java.lang.Object
implements java.lang.Iterable
CompositeNode.selectNodes(java.lang.String) method.
To learn more, visit the Aspose.Words Document Object Model (DOM) documentation article.
NodeList is returned by CompositeNode.selectNodes(java.lang.String) and contains a collection of nodes matching the XPath query.
NodeList supports indexed access and iteration.
| Modifier | Constructor and Description |
|---|---|
protected |
NodeList(java.util.List nodeList)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
Node |
get(int index)
Retrieves a node at the given index.
|
int |
getCount()
Gets the number of nodes in the list.
|
java.util.Iterator |
iterator()
Provides a simple "foreach" style iteration over the collection of nodes.
|
Node[] |
toArray()
Copies all nodes from the collection to a new array of nodes.
|
protected NodeList(java.util.List nodeList)
public Node get(int index)
The index is zero-based.
Negative indexes are allowed and indicate access from the back of the collection. For example -1 means the last item, -2 means the second before last and so on.
If index is greater than or equal to the number of items in the list, this returns a null reference.
If index is negative and its absolute value is greater than the number of items in the list, this returns a null reference.
index - An index into the list of nodes.Node value.public int getCount()
public Node[] toArray()
You should not be adding/removing nodes while iterating over a collection of nodes because it invalidates the iterator and requires refreshes for live collections.
To be able to add/remove nodes during iteration, use this method to copy nodes into a fixed-size array and then iterate over the array.
public java.util.Iterator iterator()
iterator in interface java.lang.Iterable