Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3239714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:00:08+00:00 2026-05-17T18:00:08+00:00

I need parse a select value in html file. I have this html file:

  • 0

I need parse a select value in html file. I have this html file:

<html>
<head></head>
<body>
    <select id="region" name="region">
        <option value="0"  selected>Všetky regiony</option> 
        <optgroup>Banskobystrický kraj</optgroup>
        <option value="k_1">Banskobystrický kraj</option>
        <option value="1">Banská Bystrica</option>
        <option value="3">Banská Štiavnica</option>
        <option value="18">Brezno</option>
        <option value="22">Detva</option>
        <option value="58">Dudince</option>
    </select>
</body>
</html>

I need get select option value and also text value in dictionary. I load this file in webBrowser component a try get select tag by ID “region”.

        webBrowser1.Url = new Uri("file://\\C:\\1.html");

        if (webBrowser1.Document != null)
        {
            HtmlElement elems = webBrowser1.Document.GetElementById("region");
        }

But object elems is null, I don’t why. Any advance?

EDIT: Problem was resolved with Html Agillity Pack. Thank for everybody. I was stupid, I had rather listen to your advice with Html Agillity Pack first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:00:09+00:00Added an answer on May 17, 2026 at 6:00 pm

    You can do it with the HtmlAgilityPack. There are many examples of using it to parsing html. You can find via a google search. Here are a few:

    http://htmlagilitypack.codeplex.com/wikipage?title=Examples&referringTitle=Home

    How to use HTML Agility pack

    UPDATE:

    While I think using the library is a better choice, you can do it with the webbrowser control in the following manner:

        webBrowser1.DocumentCompleted += 
              new WebBrowserDocumentCompletedEventHandler(ParseOptions);
    
        webBrowser1.Url = new Uri("C:\\1.html", UriKind.Absolute);
    
        private void ParseOptions(object sender,
            WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlElement elems = webBrowser1.Document.GetElementById("region");
        }
    

    Notice that the parsing is done in the DocumentCompleted event handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to parse a file for lines of data that start with this pattern
Deal all, Assume I have a XML file and I need to parse it
So I have this code running pretty well.. lately.. and I need to select
I have a lists of html select boxes say 30. I need to give
I need parse through a file and do some processing into it. The file
I need to parse/extract information from an html page. Basically what I'm doing is
When I make my httppost call, i need to get the selected value and
I have an XML File with Elements that look like the following: <level> <name>Name
I have this XML file : http://dl.dropbox.com/u/10773282/2011/perf.xml It has two Class elements as is
I need to select an integer value from a table: int id = from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.