Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I can use from this cod to get web tags text
code

C#
private void button1_Click(object sender, EventArgs e)
    {
         HtmlDocument doc = this.webBrowser1.Document;

        textBox1.Text=doc.GetElementById("text id").GetAttribute("value");

    }


Web:

ASP
<input id="text id" value="123">



But, I cannot to do this for this web tags...

Web:

ASP
<input  value="123">


What I have tried:

i want to get text from a web site to use it text in my windows form application
Posted
Updated 1-May-16 22:09pm
v2

1 solution

You have to use GetElementsByTagName method for that like:

C#
var inputs = doc.GetElementsByTagName("input");


it will return a collection, you have to iterate over it in a loop to get values:

C#
foreach (HtmlElement input in inputs)
{
     
     var val = input.GetAttribute("value");
}
 
Share this answer
 
Comments
Karthik_Mahalingam 1-May-16 14:53pm    
5
Ehsan Sajjad 1-May-16 15:36pm    
Thanks KARTHIK

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