Generating docx file from HTML file using OpenXML
<p>I'm using this method for generating <code>docx</code> file:</p>

<pre><code>public static void CreateDocument(string documentFileName, string text)
{
    using (WordprocessingDocument wordDoc =
        WordprocessingDocument.Create(documentFileName, WordprocessingDocumentType.Document))
    {
        MainDocumentPart mainPart = wordDoc.AddMainDocumentPart();

        string docXml =
                    @"&lt;?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?&gt;
                 &lt;w:document xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main""&gt;
                 &lt;w:body&gt;&lt;w:p&gt;&lt;w:r&gt;&lt;w:t&gt;#REPLACE#&lt;/w:t&gt;&lt;/w:r&gt;&lt;/w:p&gt;&lt;/w:body&gt;
                 &lt;/w:document&gt;";

        docXml = docXml.Replace("#REPLACE#", text);

        using (Stream stream = mainPart.GetStream())
        {
            byte[] buf = (new UTF8Encoding()).GetBytes(docXml);
            stream.Write(buf, 0, buf.Length);
        }
    }
}
</code></pre>

<p>It works like a charm:</p>

<pre><code>CreateDocument("test.docx", "Hello");
</code></pre>

<p>But what if I want to put HTML content instead of <code>Hello</code>? for example:</p>

<pre><code>CreateDocument("test.docx", @"&lt;html&gt;&lt;head&gt;&lt;/head&gt;
                              &lt;body&gt;
                                    &lt;h1&gt;Hello&lt;/h1&gt;
                              &lt;/body&gt;
                        &lt;/html&gt;");
</code></pre>

<p>Or something like this:</p>

<pre><code>CreateDocument("test.docx", @"Hello&lt;BR&gt;
                                    This is a simple text&lt;BR&gt;
                                    Third paragraph&lt;BR&gt;
                                    Sign
                        ");
</code></pre>

<p>both cases creates an invalid structure for <code>document.xml</code>. 
Any idea? How can I generate a docx file from a HTML content?</p>