ApiExamples.ExNode.TraverseAllNodes C# (CSharp) Метод

TraverseAllNodes() публичный Метод

A simple function that will walk through all children of a specified node recursively and print the type of each node to the screen.
public TraverseAllNodes ( CompositeNode parentNode ) : void
parentNode CompositeNode
Результат void
        public void TraverseAllNodes(CompositeNode parentNode)
        {
            // This is the most efficient way to loop through immediate children of a node.
            for (Node childNode = parentNode.FirstChild; childNode != null; childNode = childNode.NextSibling)
            {
                // Do some useful work.
                Console.WriteLine(Node.NodeTypeToString(childNode.NodeType));

                // Recurse into the node if it is a composite node.
                if (childNode.IsComposite)
                    this.TraverseAllNodes((CompositeNode)childNode);
            }
        }
        //ExEnd