ASPOSE home

com.aspose.words
Class NodeList

java.lang.Object
    extended by com.aspose.words.NodeList
All Implemented Interfaces:
java.lang.Iterable

public class NodeList
extends java.lang.Object

Represents a collection of nodes.

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.

Note: Treat the NodeList collection as a "snapshot" collection. NodeList starts as a "live" collection because the nodes are not actually retrieved when the XPath query is run. The nodes are only retrieved upon access and at this time the node and all nodes that precede it are cached forming a "snapshot" collection.

Property Getters/Setters Summary
intgetCount()
           Gets the number of nodes in the list.
Nodeget(int index)
           Retrieves a node at the given index.
 
Method Summary
java.util.Iteratoriterator()
           Provides a simple "foreach" style iteration over the collection of nodes.
Aspose.Words.Node[]toArray()
           Copies all nodes from the collection to a new array of nodes.
 

Property Getters/Setters Detail

getCount

public int getCount()
Gets the number of nodes in the list.

get

public Node get(int index)
Retrieves a node at the given 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.

Parameters:
index - An index into the list of nodes.

Method Detail

iterator

public java.util.Iterator iterator()
Provides a simple "foreach" style iteration over the collection of nodes.
Returns:
An Iterator.

toArray

public Aspose.Words.Node[] toArray()
Copies all nodes from the collection to a new array of nodes.

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.

Returns:
An array of nodes.

See Also:
          Wiki - the home page for the Aspose.Words Product Documentation that includes Programmer's Guide, Knowledge Base and other articles.
          Aspose.Words Support Forum - our preferred method of support.
          Aspose.Words Team - contact Aspose.Words Team.


ASPOSE home