public abstract class CompositeNode extends Node implements java.lang.Iterable
To learn more, visit the Aspose.Words Document Object Model (DOM) documentation article.
A document is represented as a tree of nodes, similar to DOM or XmlDocument.
For more info see the Composite design pattern.
The CompositeNode class:
| Modifier | Constructor and Description |
|---|---|
protected |
CompositeNode()
Initializes a new instance of this class.
|
protected |
CompositeNode(DocumentBase doc)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
acceptChildren(DocumentVisitor visitor) |
protected boolean |
acceptCore(DocumentVisitor visitor) |
Node |
appendChild(Node newChild)
Adds the specified node to the end of the list of child nodes for this node.
|
protected void |
coreRemoveSelfOnly() |
Node |
getChild(int nodeType,
int index,
boolean isDeep) |
NodeCollection |
getChildNodes()
Gets all immediate child nodes of this node.
|
NodeCollection |
getChildNodes(int nodeType,
boolean isDeep) |
CompositeNode |
getContainer() |
int |
getCount()
Gets the number of immediate children of this node.
|
Node |
getCurrentNode() |
Node |
getFirstChild()
Gets the first child of the node.
|
Node |
getLastChild()
Gets the last child of the node.
|
Node |
getNextMatchingNode(Node curNode) |
java.lang.String |
getText()
Gets the text of this node and of all its children.
|
boolean |
hasChildNodes()
Returns true if this node has any child nodes.
|
int |
indexOf(Node child)
Returns the index of the specified child node in the child node array.
|
Node |
insertAfter(Node newChild,
Node refChild)
Inserts the specified node immediately after the specified reference node.
|
Node |
insertBefore(Node newChild,
Node refChild)
Inserts the specified node immediately before the specified reference node.
|
boolean |
isComposite()
Returns true as this node can have child nodes.
|
java.util.Iterator |
iterator()
Provides support for the for each style iteration over the child nodes of this node.
|
Node |
prependChild(Node newChild)
Adds the specified node to the beginning of the list of child nodes for this node.
|
void |
removeAllChildren()
Removes all the child nodes of the current node.
|
Node |
removeChild(Node oldChild)
Removes the specified child node.
|
void |
removeSmartTags()
Removes all
SmartTag descendant nodes of the current node. |
NodeList |
selectNodes(java.lang.String xpath)
Selects a list of nodes matching the XPath expression.
|
Node |
selectSingleNode(java.lang.String xpath)
Selects the first Node that matches the XPath expression.
|
accept, dd, deepClone, getAncestor, getAncestor, getCustomNodeId, getDocument, getNextSibling, getNodeType, getParentNode, getPreviousSibling, getRange, memberwiseClone, nextPreOrder, nodeTypeToString, previousPreOrder, remove, setCustomNodeId, toString, toString, toString, visitorActionToBoolprotected CompositeNode()
protected CompositeNode(DocumentBase doc)
protected void coreRemoveSelfOnly()
public boolean isComposite()
isComposite in class Nodepublic boolean hasChildNodes()
public NodeCollection getChildNodes()
Note, getChildNodes() is equivalent to calling GetChildNodes(NodeType.Any, false) and creates and returns a new collection every time it is accessed.
If there are no child nodes, this property returns an empty collection.
public Node getFirstChild()
public Node getLastChild()
public int getCount()
public java.lang.String getText()
The returned string includes all control and special characters as described in ControlChar.
public NodeCollection getChildNodes(int nodeType, boolean isDeep)
public Node getChild(int nodeType, int index, boolean isDeep)
public NodeList selectNodes(java.lang.String xpath)
Only expressions with element names are supported at the moment. Expressions that use attribute names are not supported.
xpath - The XPath expression.public Node selectSingleNode(java.lang.String xpath)
Only expressions with element names are supported at the moment. Expressions that use attribute names are not supported.
xpath - The XPath expression.public java.util.Iterator iterator()
iterator in interface java.lang.Iterablepublic Node appendChild(Node newChild)
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use M:Aspose.Words.DocumentBase.ImportNode(Aspose.Words.Node,System.Boolean,Aspose.Words.ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild - The node to add.public Node prependChild(Node newChild)
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use M:Aspose.Words.DocumentBase.ImportNode(Aspose.Words.Node,System.Boolean,Aspose.Words.ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild - The node to add.public Node insertAfter(Node newChild, Node refChild)
If refChild is null, inserts newChild at the beginning of the list of child nodes.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use M:Aspose.Words.DocumentBase.ImportNode(Aspose.Words.Node,System.Boolean,Aspose.Words.ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild - The Node to insert.refChild - The Node that is the reference node. The newNode is placed after the refNode.public Node insertBefore(Node newChild, Node refChild)
If refChild is null, inserts newChild at the end of the list of child nodes.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use M:Aspose.Words.DocumentBase.ImportNode(Aspose.Words.Node,System.Boolean,Aspose.Words.ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild - The Node to insert.refChild - The Node that is the reference node. The newChild is placed before this node.public Node removeChild(Node oldChild)
The parent of oldChild is set to null after the node is removed.
oldChild - The node to remove.public void removeAllChildren()
public void removeSmartTags()
SmartTag descendant nodes of the current node.
This method does not remove the content of the smart tags.public int indexOf(Node child)
protected boolean acceptCore(DocumentVisitor visitor) throws java.lang.Exception
java.lang.Exceptionprotected boolean acceptChildren(DocumentVisitor visitor) throws java.lang.Exception
java.lang.Exceptionpublic Node getCurrentNode()
public CompositeNode getContainer()