Philippe Renaud
asked on
Find nodes in HtmlNodeCollection
Hello EE,
I have in my vb.net project HtmlUtilityPack import.
Im trying to find a Div and the result I insert in a HtmlNodeCollection like this :
but inside this DIV there are many <a href='www.something.com' 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
list.add(node.SelectNode(" a").GetAtt ribute('ti tle"))
Next
can you help ?
thanks
I have in my vb.net 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']")
but inside this DIV there are many <a href='www.something.com' 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
list.add(node.SelectNode("
Next
can you help ?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
list.add(node.SelectSingleNode("a").Attributes("title").Value)
Next
ASKER
Thank you
ASKER
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