I am new to C#. I have been working on a C# console project. I sent a request to a server and get a very lengthy response string (html format). I want to extract and get some information from this string. If I use javascript I know how to fetch. This is console project. How do I extract it? Thanks.

Try the HTMLDocument class.

Use regular expression to extract some string from the long string (HTML message), give me an example and may I help you by give you regular expression pattern to extract data by.

There is a drop-down (html select list) in the html source. I want to fetch all the values within that select box (option items). I don't want to use forms. This is console app. Please adivce.

<select name="listnames" id="listnames">
<option value="190">my data 1</option>
<option value="1930">my data 2</option>

As Ramy suggested, you can use regexp to parse the response string. However, it might get tricky if there are multiple dropdowns.

Jeff Heaton has written a parser in C# which would be just the one you are looking for ... search for "Parsing HTML in Microsoft C# By Jeff Heaton" and you would get his article with the code.

I have only one select drop down in my response text. Can you tell me with some code, how to get option value using regular expression. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.