extracting all forms from an html page with all their inputs using HtmlAgilityPack and VB.NET

Topics: Developer Forum
Feb 23, 2015 at 10:36 PM
Edited Feb 23, 2015 at 10:37 PM
hi
How can I get all the forms from a page using HtmlAgilityPack with all their input fields. I have the following code:
Try
            Dim Web As New System.Net.WebClient
            Dim htdoc As New HtmlAgilityPack.HtmlDocument
            Dim page As String = ""
            page = Web.DownloadString("http://test.com/student/register.php")
            htdoc.LoadHtml(page)
            For Each item As HtmlNode In htdoc.DocumentNode.Descendants("form")
                    MsgBox(item.OuterHtml)
            Next

        Catch ex As Exception
        End Try
example of an html page:
<HTML>
<BODY>
<STRONG>TEST</STRONG>
<STRONG>TEST</STRONG>
<STRONG>TEST</STRONG>
<form action="register.php?do=checkdate" method="post" onsubmit="return checkform(this)">
<input type="hidden" name="do" value="checkdate">
<input type="hidden" name="s" value="X">
<input type="hidden" name="securitytoken" value="guest">
<input type="hidden" name="url" value="https://www.google.com/">
</form>
<STRONG>TEST</STRONG>
<STRONG>TEST</STRONG>
<STRONG>TEST</STRONG>
<form action="index.php" method="get" style="clear:left">
<td class="tfoot" align="right" width="100%">
        <div class="smallfont">
            <strong>
                <a href="https://support.test.com/?s=5413e493b8e32114ba2ff4d2e038ace3" rel="nofollow" accesskey="9">Contact Us</a> -
                <a href="http://store.test.com/">Steam Store</a> -

            <a href="archive/index.php">Archive</a> -
                <a href="http://store.test.com/privacy_agreement/">Privacy Statement</a> -
                <a href="http://store.test.com/subscriber_agreement/">Terms of Service</a> -
                <a href="#top" onclick="self.scrollTo(0, 0); return false;">Top</a>
            </strong>
        </div>
</td>
</form>
<STRONG>TEST</STRONG>
<STRONG>TEST</STRONG>
<STRONG>TEST</STRONG>
<form id="searchform" name="searchform" method="get" action="http://store.test.com/search/" onsubmit="return SearchSuggestCheckTerm(this);">
</form>
</BODY>
</HTML>
all i get after executing this code is the form tag without its descendants.