title: Generating HTML file using XML file in C# windows form
body: <p>I am trying to generate class by which I can generate a HTML code from an XML file. It does generate the HTML code but when I have more than one tag in my XML file its value is reset.</p>
  
  <p>I hope you could help me.</p>
  
  <p>Here is my code in C#:</p>
  
  <pre><code>public class GenerateHTMLClass
  {
      public string htmlstringbegin = "&lt;HTML&gt;&lt;HEADER&gt;&lt;title&gt;My Web-page&lt;/title&gt;&lt;/HEADER&gt;&lt;BODY&gt;&lt;form&gt;\r\n";
      public string htmlstringend = "&lt;/form&gt;&lt;/BODY&gt;&lt;/HTML&gt;";
      public string htmlstring = "";
  
      public GenerateHTMLClass(string xmlfileaddress, string htmlfilenaddress)
      {
          string id = "";
          string name = "";
          string type = "";
          string value = "";
          string htmlstring = "";
          XmlTextReader reader = new XmlTextReader(xmlfileaddress);            
          while (reader.Read())
          {
              switch (reader.Name)
              {
                  case "GUID":
                      id = reader.ReadString();
                      break;
                  case "Title":
                      name = reader.ReadString();
                      break;
                  case "Type":
                      type = reader.ReadString();
                      break;
              }              
          }
          htmlstring += "&lt;" + type + " id=" + id + " value=" + name + "/&gt;" + name + "&lt;/" + type + "&gt;";
          using (FileStream fs = new FileStream(htmlfilenaddress, FileMode.Create))
          {
              using (StreamWriter writer = new StreamWriter(fs, Encoding.UTF8))
              {
                  writer.Write(htmlstringbegin + htmlstring + htmlstringend);
              }
          }
      }
  }
  </code></pre>
  
  <p>My xml file:</p>
  
  <pre><code>&lt;Groups&gt;
  &lt;Group1&gt;
      &lt;Item1&gt;
          &lt;Type&gt;Button&lt;/Type&gt;     
          &lt;GUID&gt;124342345&lt;/GUID&gt;
          &lt;Title&gt;Name&lt;/Title&gt;
      &lt;/Item1&gt;
  &lt;/Group1&gt;
  &lt;Group2&gt;
      &lt;Item2&gt;
          &lt;Type&gt;textarea&lt;/Type&gt;   
          &lt;GUID&gt;1243dsfs42345&lt;/GUID&gt;
          &lt;Title&gt;Name&lt;/Title&gt;     
      &lt;/Item2&gt;
  &lt;/Group2&gt;
  &lt;/Groups&gt;
  </code></pre>