Framework > System Layer > Document Object Model > Nodes |
In general there are two types of nodes:
Common for all types of nodes is that you can obtain the immediate node parent as well as the root node (the topmost node in the hierarchy). For example:
C# |
Copy Code
|
---|---|
// obtain the node parent in the scene INNode parent = node.ParentNode; // obtain the scene root INNode root = node.RootNode; |
Visual Basic |
Copy Code
|
---|---|
' obtain the node parent in the scene Dim parent as INNode = node.ParentNode ' obtain the scene root Dim root as INNode = node.RootNode |
Branch nodes can also be classified as follows:
C# |
Copy Code
|
---|---|
// get the container child nodes NNodeList children = container.Children(null); // get the child at some index INNode child = container.GetChildAt(0); // get the container descendant nodes NNodeList descendants = container.Descendants(null); |
Visual Basic |
Copy Code
|
---|---|
' get the container child nodes Dim children As NNodeList = container.Children(Nothing) ' get the child at some index Dim child As INNode = container.GetChildAt(0) ' get the container descendant nodes Dim descendants As NNodeList = container.Descendants(Nothing, -1) |
C# |
Copy Code
|
---|---|
// add a child node composite.AddChild(node1); // insert a child node composite.InsertChild(0, node2); // remove a child node composite.RemoveChild(node1); // remove a child at some index composite.RemoveChildAt(0); |
Visual Basic |
Copy Code
|
---|---|
' add a child node composite.AddChild(node1) ' insert a child node composite.InsertChild(0, node2) ' remove a child node composite.RemoveChild(node1) ' remove a child at some index composite.RemoveChildAt(0) |
It is also often required to enumerate the nodes, which reside in the sub tree of a particular node container. The Nevron DOM provides two types of node tree enumerators - forward and reversed. They both support the following tree traversal orders:
C# |
Copy Code
|
---|---|
// forward enumeration NNodeTreeEnumerator en = new NNodeTreeEnumerator(nodeContainer, null, -1, TreeTraversalOrder.DepthFirstPreOrder); while (en.MoveNext()) { INNode cur = (INNode)en.Current; } // reverse enumeration NReverseNodeTreeEnumerator ren = new NReverseNodeTreeEnumerator(nodeContainer, null, -1, TreeTraversalOrder.DepthFirstPreOrder); while (ren.MoveNext()) { INNode cur = (INNode)en.Current; } |
Visual Basic |
Copy Code
|
---|---|
' forward enumeration Dim en As New NNodeTreeEnumerator(nodeContainer, Nothing, -1, TreeTraversalOrder.DepthFirstPreOrder) While en.MoveNext() Dim cur As INNode = en.Current End While ' reverse enumeration Dim ren As New NReverseNodeTreeEnumerator(nodeContainer, Nothing, -1, TreeTraversalOrder.DepthFirstPreOrder) While ren.MoveNext() Dim cur As INNode = ren.Current End While |