예제 #1
0
        public static void FromHtml(RichTextBlock rtb, string html)
        {
            var oldHtml = html;

            html = System.Net.WebUtility.HtmlDecode(html);
            html = html.Replace("&bull;", "<br />    - ");
            html = html.Replace("&middot;", "<br />    - ");
            html = html.Replace("<li>", "    - ").Replace("</li>", "<br />").Replace("<ul>", "<p>").Replace("</ul>", "</p>");

            html = html.Replace("<br /><br /><p>", "<br /><p>");

            html = $"<html><body><p>{html}</p></body></html>";
            var v           = new XmlConvert();
            var htmlFromDoc = v.Convert(html);

            htmlFromDoc = htmlFromDoc.Replace("<p />", "");
            XmlDocument document = new XmlDocument();

            document.LoadXml(htmlFromDoc);

            XmlElement elem = (XmlElement)(document.GetElementsByTagName("body")[0]);

            var container = new RichTextBlockTextContainer(rtb);

            ParseElement(elem, container);
        }
예제 #2
0
        public static void FromHtml(RichTextBlock rtb, string html)
        {
            var oldHtml = html;
            html = System.Net.WebUtility.HtmlDecode(html);
            html = html.Replace("&bull;", "<br />    - ");
            html = html.Replace("&middot;", "<br />    - ");
            html = html.Replace("<li>", "    - ").Replace("</li>", "<br />").Replace("<ul>","<p>").Replace("</ul>","</p>");
            
            html = html.Replace("<br /><br /><p>", "<br /><p>");

            html = $"<html><body><p>{html}</p></body></html>";
            var v = new XmlConvert();
            var htmlFromDoc = v.Convert(html);
            htmlFromDoc = htmlFromDoc.Replace("<p />", "");
            XmlDocument document = new XmlDocument();
            document.LoadXml(htmlFromDoc);

            XmlElement elem = (XmlElement)(document.GetElementsByTagName("body")[0]);

            var container = new RichTextBlockTextContainer(rtb);
            
            ParseElement(elem, container);
        }