Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

Find nodes in HtmlNodeCollection

Hello EE,

I have in my project HtmlUtilityPack import.

Im trying to find a Div and the result I insert in a HtmlNodeCollection like this :

        Dim nodes As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//div[@id='myID']")

Open in new window

but inside this DIV there are many <a href='' title='hello'></a>

I want all the title attribute of al of them. but only in that specific div..

im not sure where to go with this... should be soemthing like :

Dim list as new List(of string)
For Each node As HtmlNode In nodes

can you help ?
Avatar of kaufmed
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Philippe Renaud


yes sorry agility.

but it cant be done on 2 lines? i need to do it on doc.DocumentNode?

i cannot do it on the nodes variable to reach @a?

because otherwise i always need to re-iterate on doc variable and sometimes there is tons of source code lines, but still maybe its fast also.. i dont know
I'm probably not understanding what you are asking, but if you would like to stick with the logic you currently have, then it should be along the lines of:

For Each node As HtmlNode In nodes

Open in new window

Thank you