Gets next node according to the pre-order tree traversal algorithm.
Namespace:
Aspose.Words
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 21.2.0
Syntax
public Node NextPreOrder(
Node rootNode
)
Public Function NextPreOrder (
rootNode As Node
) As Node
public:
Node^ NextPreOrder(
Node^ rootNode
)
member NextPreOrder :
rootNode : Node -> Node
Parameters
- rootNode
- Type: Aspose.WordsNode
The top node (limit) of traversal.
Return Value
Type:
NodeNext node in pre-order order. Null if reached the rootNode.
Examples
Shows how to traverse the document's node tree using the pre-order traversal algorithm, and delete any encountered shape with an image.
Document doc = new Document(MyDir + "Images.docx");
Assert.AreEqual(9,
doc.GetChildNodes(NodeType.Shape, true).OfType<Shape>().Count(s => s.HasImage));
Node curNode = doc;
while (curNode != null)
{
Node nextNode = curNode.NextPreOrder(doc);
if (curNode.PreviousPreOrder(doc) != null && nextNode != null)
Assert.AreEqual(curNode, nextNode.PreviousPreOrder(doc));
if (curNode.NodeType == NodeType.Shape && ((Shape)curNode).HasImage)
curNode.Remove();
curNode = nextNode;
}
Assert.AreEqual(0,
doc.GetChildNodes(NodeType.Shape, true).OfType<Shape>().Count(s => s.HasImage));
See Also