c#.net parsing HTML -


I am creating a webpage that will retrieve some form data from several other pages. For example, hidden Form Field:

  & lt; Input type = "hidden" id = "thefield" value = "thegoods" />   

Now there is always one ID in this area, but sometimes written with double quotes ("), sometimes a single (') and sometimes none. Therefore, it is difficult to do just that, to recover the necessary information, an "index".

Do not in any way return the value of form elements in C # .net in a jquery way

Unwin

Any help appreciated .

Example:

 

The easiest way is probably using. code> HtmlAgilityPack. HtmlDocument Doc = New HtmlAgilityPack.HtmlDocument (); doc.Load ("test.html"); HtmlNode node = doc.DocumentNode.SelectSingleNode ("// input [@ id = 'thefield']"); var value = node. Properties ["Value"]. Value; // "thegoods"

Edit:

Local to load an HTML page Instead of using the file HtmlWeb :

  HTML web HTMLWeb = new HtmlWeb (); HtmlDocument Doc = htmlWeb.Load ("http://stackoverflow.com"); ...    

Comments