title: Correctly using gumbo-parser to iterate and find the things I need?
body: <p>I'm working on a pure C99 practising project which can do a login simulation for our school's CAS login system.</p>
  
  <p>Now I'm trying to use Gumbo HTML parser to parse our school's login page. Here is the form section and I need to get the login ticket from it before I run the POST request to submit the form, which is <strong>the "hidden" type input element with name "lt".</strong> (i.e. line with <code>&lt;input type="hidden" name="lt" value="LT-000000-b4LktCXyzXyzXyzXyzXyzXyz" /&gt;</code>, and I need to parse the "value").</p>
  
  <p>I've wrote some code, but it seems cannot find out this input element. Here is my C program's function:</p>
  
  <pre><code>const char * parse_login_ticket_old(char * raw_html)
  {
      // Parse HTML into Gumbo memory structure
      GumboOutput * gumbo_output = gumbo_parse(raw_html);
  
      // Prepare the node
      GumboNode * gumbo_root = gumbo_output-&gt;root;
  
      assert(gumbo_root-&gt;type == GUMBO_NODE_ELEMENT);
      assert(gumbo_root-&gt;v.element.children.length &gt;= 2);
  
      const GumboVector* root_children = &amp;gumbo_root-&gt;v.element.children;
  
      GumboNode* page_body = NULL;
  
  
      for (int i = 0; i &lt; root_children-&gt;length; ++i)
      {
          GumboNode* child = root_children-&gt;data[i];
          if (child-&gt;type == GUMBO_NODE_ELEMENT &amp;&amp; child-&gt;v.element.tag == GUMBO_TAG_BODY)
          {
              page_body = child;
              break;
          }
      }
  
      assert(page_body != NULL);
  
      GumboVector* page_body_children = &amp;page_body-&gt;v.element.children;
  
      for (int i = 0; i &lt; page_body_children-&gt;length; ++i)
      {
          GumboNode* child = page_body_children-&gt;data[i];
  
          GumboAttribute * input_name_attr = gumbo_get_attribute(&amp;child-&gt;v.element.attributes, "name");
  
          if (child-&gt;type == GUMBO_NODE_ELEMENT &amp;&amp; child-&gt;v.element.tag == GUMBO_TAG_INPUT &amp;&amp; strcmp(input_name_attr-&gt;value, "lt") == 0)
          {
              GumboAttribute * input_value_attr = gumbo_get_attribute(&amp;child-&gt;v.element.attributes, "value");
              return input_name_attr-&gt;value;
          }
      }
  
      return NULL;
  }
  </code></pre>
  
  <p>In case someone need for debugging, here is a example of our schools page. Possible sensitive data has been removed.</p>
  
  <pre><code>&lt;body&gt;
      &lt;div id="wrapper"&gt;
          &lt;div id="contentArea" role="main"&gt;
              &lt;div class="form login" role="form"&gt;
                  &lt;h2 class="hidden"&gt;Login&lt;/h2&gt;
                  &lt;form id="fm1" class="fm-v clearfix" action="/schoolcas/login?jsessionid=1234567890" method="post"&gt;&lt;div class="formRow"&gt;
                          &lt;label for="username" class="label"&gt;Student ID&lt;/label&gt;
                          &lt;div class="textBox"&gt;
                              &lt;input id="username" name="username" class="schoolcas text" aria-required="true" type="text" value="" size="25" maxlength="25"/&gt;&lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="formRow"&gt;
                          &lt;label for="password" class="label"&gt;Password&lt;/label&gt;
                          &lt;div class="textBox"&gt;
                              &lt;input id="password" name="password" class="schoolcas text" aria-required="true" type="password" value="" size="25" autocomplete="off"/&gt;&lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="formRow"&gt;
                          &lt;input type="hidden" name="lt" value="LT-000000-b4LktCXyzXyzXyzXyzXyzXyz" /&gt;
                          &lt;input type="hidden" name="execution" value="e2s1" /&gt;
                          &lt;input type="hidden" name="_eventId" value="submit" /&gt;
                          &lt;input class="button grey submit" name="submit" value="Login" type="submit" /&gt;
                      &lt;/div&gt;
  
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Anyway, my program seems just stop at the top of the body element and it returns NULL later on. </p>
  
  <p><strong>So I would like to know how to do a correct search, and find out the input element I need?</strong></p>