Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Find nodes in HtmlNodeCollection

Posted on 2013-01-04
Medium Priority
Last Modified: 2013-01-04
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 ?
Question by:PhilippeRenaud
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 38745344
Do you mean HTML Agility Pack? If so, you can set up your XPath to select that attribute for you.


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

Open in new window

Then you could just iterate over that result set:

Dim list as new List(of string)

For Each node As HtmlNode In nodes

Open in new window


Author Comment

ID: 38745736
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
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38745819
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


Author Closing Comment

ID: 38746076
Thank you

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question