This project has moved. For the latest updates, please go here.

Parsing tags with attributes

Topics: Developer Forum, Project Management Forum, User Forum
Jun 6, 2011 at 1:29 PM

i have this code

Dim htmldoc As HtmlDocument = New HtmlDocument()
Dim root As HtmlNode = htmldoc.DocumentNode

For Each link As HtmlNode In root.SelectNodes("//a")
If link.HasAttributes("href") Then doSomething() 'this doesn't work because hasAttributes only checks whether an element has attributes or not

but am getting an error  Object reference not set to an instance of an object.

the document contains at least one anchor-tag? how do i check if an attribute exits?

i tried this `if link.HasAttributes("title") then` and get another error

`Public ReadOnly Property HasAttributes() As Boolean' has no parameters and its return type cannot be indexed.`