Currently, I am extracting the class of all <a>
elements in an HTML document of a webpage using VB.net from a WinForm:
Dim htmlLinks As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("a")
For Each link As HtmlElement In htmlLinks
Console.WriteLine(link.GetAttribute("classname").ToString)
Next
For illustration, here is a snippet from the HTML document :
<a href="/test.php" class="nav">Item1</a>
<a class="link-download" href="http://test.net/media/26.mp4">MP4 File</a>
The VB code provided above only captures the Class
attribute of the first a
element with href
, missing out on the second instance where class
appears before href
.
<a class="link-download" href="http://test.net/media/26.mp4">MP4 File</a>
This implies that the current VB code only returns the class name as nav
.
Does this explanation clarify the issue at hand?
I seek guidance on how to retrieve the attributes of all the <a>
elements mentioned earlier.
Can anyone provide insights on achieving this?