want to get htmlelemt for link in webpage

bhavin12300

Active member
Joined
Sep 18, 2007
Messages
44
Programming Experience
Beginner
hi
i am creating one small application in which i am using webbrowser control to visit web page.
after displaying the webpage i am using documnet property of webbrowser control to obtain the html page(htmldocument object).

now there are some links on that page of which htmlelement object i want to access.i am not able to use the property (gethtmlelementbyid)of htmldocument object because there is no id in html code.(as shown belove)

VB.NET:
<html>
<body>
<input type="textbox" name="textbox1">
<a href="http://localhoest" class="bhavin">hiiii</a>
</body>
</html>

so anyone tell me how do i get the htmlelement object of this link on my page in vb.net application so that i can resume my job from there.

waiting for your reply.

is it must to provide id to html element on page to to use gethtmlelemtbyid?
is there any other way to get htmlelement object of this link???
waiting for your reply
 
Peculiar you didn't notice GetElementsByTagName method. You can also get it with Links property.
 
can u give me example code with getelementbytag in it?
also code of html page from which you are getting htmlelement for link tag.
waiting
thanks for above reply
 
something like this:
VB.NET:
dim links as HtmlElementCollection 
links = me.Webbrowser1.Document.GetElementsByTagName("a")
'or
links = me.Webbrowser1.Document.links
GetElementsByTagName is also a method of HtmlElement, so you can get a narrower collection if that helps the collecting.
 
Back
Top