title: Working effectivly with HTML in embeed web-server inside a .net/wpf-app
body: <p>I have a pretty complex composite application (.NET/WPF/Prism). It runs on some kind of embedded devices (with full fledge window 7), let's call them "kiosks". I need to allow remote control for the applicaton. i.e. it should have an embedded web-server which will provide some information via http/html for remote control (checking status, logs, etc).</p>
  
  <p>So in some application's module I need to compose HTML to return it. This seems to be pretty tedious. It looks like:</p>
  
  <pre><code>using (Stream ostr = ...)
  using (TextWriter tw = new StreamWriter(ostr))
  {
      tw.WriteLine("&lt;html&gt;");
      tw.WriteLine("&lt;head&gt;");
      tw.WriteLine("&lt;title&gt;Web Console&lt;/title&gt;");
      tw.WriteLine("&lt;meta http-equiv=\"refresh\" content=\"2\" /&gt;");
  }
  </code></pre>
  
  <p>I want to simplify HTML creation process. So I'm looking for some kind of .NET HTML DOM library. And can't find decent one. Only one I've found so far - <a href="http://htmlagilitypack.codeplex.com" rel="nofollow noreferrer">HTML Agility Pack</a>. It looks cool but I believe it targets a bit other use-case (load some HTML and search with xpath/linq). But I need just compose HTML, not parse, not query. 
  I'd expect from a library API similar to System.Xml.Linq.</p>
  
  <p>Something like this:</p>
  
  <pre><code>HtmlDocument htmlDoc = new HtmlDocument();
  htmlDoc.Head.AddScript(ScriptLanguages.JavaScript, "http://localhost/scripts/jquery.js");
  htmlDoc.Body.Elements(
    new HtmlDiv {
      Style="align:center", 
      Content = new []{new TextBlock("Hi")} }, 
    new HtmlDiv (
      new HtmlLabel(text: "StartDate", nameFor: "dtStartDate"),
      new HtmlTextBox(clintName: "dtStartDate", style: "width:100px")
    )
  );
  </code></pre>
  
  <p>Another posibility that comes to my mind is to use some kind of templating engine. But I have no idea which one will work seamessly with embedded web-server. </p>
  
  <p>I'm open for you thoughts, thanks in advance.</p>
  
  <p>p.s. If you wonder "Embedded web-server" is <a href="http://www.codeproject.com/KB/IP/CSharpEmbeddedHTTPServer.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/IP/CSharpEmbeddedHTTPServer.aspx</a></p>