/// <summary> Utility to apply a visitor to a node list. /// Provides for a visitor to modify the contents of a page and get the /// modified HTML as a string with code like this: /// <pre> /// Parser parser = new Parser ("http://whatever"); /// NodeList list = parser.parse (null); // no filter /// list.visitAllNodesWith (visitor); /// System.out.println (list.toHtml ()); /// </pre> /// </summary> public virtual void VisitAllNodesWith(NodeVisitor visitor) { INode node; visitor.BeginParsing(); for (int i = 0; i < m_iSize; i++) { node = nodeData[i]; node.Accept(visitor); } visitor.FinishedParsing(); }
/// <summary> Apply the given visitor to the current page. /// The visitor is passed to the <code>accept()</code> method of each node /// in the page in a depth first traversal. The visitor /// <code>beginParsing()</code> method is called prior to processing the /// page and <code>finishedParsing()</code> is called after the processing. /// </summary> /// <param name="visitor">The visitor to visit all nodes with. /// </param> /// <throws> ParserException If a parse error occurs while traversing </throws> /// <summary> the page with the visitor. /// </summary> public virtual void VisitAllNodesWith(NodeVisitor visitor) { INode node; visitor.BeginParsing(); for (INodeIterator e = Elements(); e.HasMoreNodes(); ) { node = e.NextNode(); node.Accept(visitor); } visitor.FinishedParsing(); }