title: Add form tag around a body tag using HtmlAgilityPack
body: <p>How do I add a form tag around a HMLDocument?</p>
  
  <p>For the given HTML</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;p&gt;Full name: &lt;input name="FullName" type="text" value=""&gt;&lt;/p&gt; 
    &lt;p&gt;&lt;input name="btnSubmit" type="submit" value="Submit"&gt;&lt;/p&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the following code...</p>
  
  <pre><code>var doc = new HtmlDocument();
  doc.OptionAutoCloseOnEnd = true;
  doc.LoadHtml(input);
  var body = doc.DocumentNode.SelectSingleNode("//body");
  
  if (doc.DocumentNode.SelectNodes("//form[@action]") == null)
  {
      var form = doc.CreateElement("form");
      form.Attributes.Add("action", "/pages/event/10302");
      body.PrependChild(form);
  }
  return doc.DocumentNode.OuterHtml;
  </code></pre>
  
  <p>I get back the following, notice we don't have a closing <code>&lt;/form&gt;</code> tag above the closing <code>&lt;/body&gt;</code> tag</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;form action="/pages/event/10302"&gt;
    &lt;p&gt;Full name: &lt;input name="FullName" type="text" value=""&gt;&lt;/p&gt; 
    &lt;p&gt;&lt;input name="btnSubmit" type="submit" value="Submit"&gt;&lt;/p&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>