0

I want to make program in c# that will found value and show it in text box, but it's not a problem... When I tried to show this value, program spam in 1 text box, so it's impossible to read something.

    private void button1_Click(object sender, System.EventArgs e)
    {
        using (var client = new WebClient())
        {
            string input = client.DownloadString("example.com");
            textBox2.AppendText(input);
            Regex regex = new Regex("[^<b>](.*)[^</b>]", RegexOptions.IgnoreCase);
            Match match;
            for (match = regex.Match(input); match.Success; match = match.NextMatch())
            {
                foreach (Group group in match.Groups)
                {
                    textBox1.AppendText(string.Format("Value {0}", group));
                }
            }
        }
    }

1 Text box should show only the value
2 Text box show html code from page

Dalorzo
  • 19,834
  • 7
  • 55
  • 102
MKKL
  • 7
  • 1

1 Answers1

0

You can use CSQuery to parse your HTML:

https://github.com/jamietre/CsQuery

CQ dom = "<div>Hello world! <b>I am feeling bold!</b> What about <b>you?</b></div>";

string bold = dom["b"].First().InnerText;

You can select elements like JQuery

Igor Quirino
  • 1,187
  • 13
  • 28