How can I step through all nodes?

Topics: User Forum
Jun 13, 2012 at 5:25 PM

I need to be able to process all the HTML elements in sequence, as I'm looking for "context" not just a particular type of node.  For example, I want to search for a particular comment, followed by a particular H2, which is then followed by a particular A.

I have to imagine that there's a way to do this, but I'm coming up empty so far.  I'd like to have a HTMLNodeCollection that has a flat collection of the nodes.



Jun 13, 2012 at 7:44 PM



This function recurses down through all the nodes in the document in a flat list. It will recurse so as it hits a node the next nodes will be its children.

Jun 14, 2012 at 1:05 AM

How do I declare the result of this?  It shows as returning an HTMLNode.<DescendantNodes>d_10, which I 'm not sure how to declare.  I can do a for each, but I'd like to be able to break out of the loop and then continue where I left off.