Ejemplo n.º 1
0
        public string GetHtml()
        {
            XmlDocument html = new XmlDocument();

            html.AppendChild(html.CreateElement("html"));
            XmlElement element = (XmlElement)(html.DocumentElement.AppendChild(html.CreateElement("head")));

            HeadWriter.Flush();
            Encoding charset = CharSet;

            element.InnerXml = CharSet.GetString(_headStream.ToArray());
            element          = (XmlElement)(html.DocumentElement.AppendChild(html.CreateElement("head")));
            BodyWriter.Flush();
            element.InnerXml = CharSet.GetString(_bodyStream.ToArray());
            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(ms, charset))
                {
                    sw.WriteLine("<!DOCTYPE html>");
                    XmlWriterSettings settings = BodyWriter.Settings.Clone();
                    settings.ConformanceLevel = ConformanceLevel.Document;
                    using (XmlWriter writer = XmlWriter.Create(sw, settings))
                    {
                        html.WriteTo(writer);
                        writer.Flush();
                        return(charset.GetString(ms.ToArray()));
                    }
                }
            }
        }