Beispiel #1
0
        /// <summary>Start a depth-first traverse of the root and all of its descendants.</summary>
        /// <param name="root">the root node point to traverse.</param>
        public virtual void Traverse(iText.StyledXmlParser.Jsoup.Nodes.Node root)
        {
            iText.StyledXmlParser.Jsoup.Nodes.Node node = root;
            int depth = 0;

            while (node != null)
            {
                visitor.Head(node, depth);
                if (node.ChildNodeSize() > 0)
                {
                    node = node.ChildNode(0);
                    depth++;
                }
                else
                {
                    while (node.NextSibling() == null && depth > 0)
                    {
                        visitor.Tail(node, depth);
                        node = node.ParentNode();
                        depth--;
                    }
                    visitor.Tail(node, depth);
                    if (node == root)
                    {
                        break;
                    }
                    node = node.NextSibling();
                }
            }
        }