Cannot get all input, textarea, option of form

Topics: Developer Forum, User Forum
Jun 7, 2012 at 2:00 PM

Hi all

I want to get get all input, textarea, option of form but it return null. This is my code

HtmlAgilityPack.HtmlWeb web = new HtmlWeb();           

HtmlAgilityPack.HtmlDocument htmlDoc = web.Load("");         

var forms = htmlDoc.DocumentNode.Descendants("form");           

foreach (var form in forms)           


if (form.Attributes["name"] != null && form.Attributes["name"].Value == "register")                {                   

Console.WriteLine(  form.InnerHtml );                   



Pls help me to get all input, textarea, select of HTML Form

Best Regards


skype: nam.truongthanh

Jun 12, 2012 at 8:34 PM

You can use this open source project to resolve this issue.

Jun 12, 2012 at 10:59 PM

To allow form to have child elements use the modify the HtmlNode.HtmlElements collection and remove the "form" item.