Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know that how to get attribute "class" of an html element using webbrowser component in C# .. Normally i am able to get any attribute (except class attribute) of any html tag. but this time i want to get attribute of "class" here is a sample html element
<p class="abstract"> Hello World </p>

Normally i was able to get the attribute of any html tag like
<a href="http://www.anylink.com"> Hello World </a>

String = HtmlElement.GetAttribute("href"); //So it gives me the value of href attribute...

But for this html tag <p class="abstract"> Hello World </p>

I tried String = HtmlElement.GetAttribute("class");

but it doesnt worked for me :(

Edit for Answer 1: No it doesnt works.. As you know GetAttribute(<atribute name="">) returns the value of a specific attribute in an HtmlElement.. So when i use "class" or "abstract" (which is the class name) in both cases it returns nothing..
Posted
Updated 15-Jan-10 3:02am
v4

1 solution

Try as below
HtmlElement.GetAttribute("className"); 
 
Share this answer
 
Comments
ram salunke 19-Feb-13 1:54am    
Thank you so much sir ...
it also useful 4 me :-)

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