This project has moved and is read-only. For the latest updates, please go here.

Help searching through nodes. Very basic.

Topics: User Forum
Jan 13, 2011 at 4:56 PM
Edited Jan 13, 2011 at 7:56 PM

I'm using I'm able to successfully parse through the HTML and return 20 nodes that I'm interested in by doing the following.


        Dim WebGet = New HtmlWeb()
        Dim Document = WebGet.Load(Forum)
        Dim i As Integer = 0
  For Each Thread In Document.DocumentNode.SelectNodes("//tr[@class='title']") i = i + 1 Next MsgBox(i)
Doing this i can individually load a node into my HTMLNode object "Thread".

What i can't figure out is how to search for ChildNodes in the Node i just loaded into "Thread". I need to search through each node
and find the InnerHTML values of it's child nodes.

For instance, each node in Thread will have a child node with attribute "username". I need to find that child node, and retrieve it's InnterHTML
Jan 13, 2011 at 11:26 PM

It may just be missing: ... Thread.ToString() ... just started learning this but that's the first thing I'd try.



Jan 14, 2011 at 12:09 AM

I worked around it by finding the index of the child node in Thread, and then just using:


It only works if the nodes on my page remain pretty much static, which they do, so it will work for me. I still wish there was a slightly more elegant way to search for child nodes within nodes.

Jan 14, 2011 at 12:46 AM

Selecting produces collections, you're collecting attributes, i.e. "class", and I think that's the problem, nodes are tags, attributes aren't.

Think that's why you had to use an index, because you have a collection of different tags all with the same attribute. If you select a tag collection, the children will be tags.

hth, tom