Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a small test application in which i am trying to fetch the all the hyperlink's details(Anchor Text and url) on the web page. What i have done till now is that i create webbrowser component loaded the page and fetch all <a> tags. I also know that how to print the value of "href" attribute. I am having trouble to get the text on which link is applied (i.e anchor text).

Here is the code which i have done till now.
Uri page = new Uri("http://www.yahoo.com");
webBrowser1.Url = page;
HtmlElementCollection aTags = WebBrowser1.Document.GetElementsByTagName("a");
textBox1.Text= aTags[0].GetAttribute("href");


now the textbox1 contains the address of the 1st link. but how to get the anchor text ??
Posted
Updated 3-Jan-10 2:38am
v4

Does aTags[0].InnerText do it?
 
Share this answer
 
Just quickly and without testing, it should be as easy as aTags[0].InnerText.
 
Share this answer
 
yes aTags[0].InnerText works also aTags[0].InnerHtml works too. thanks to all
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900