Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string filename = @"..\..\..\HtmlRenderer.Demo\Samples\ClassicSamples\00.Intro.htm";

            //1. blank html
            var fileContent = "<html><body><div id=\"a\">AAA</div></body></html>";

            easeViewport.LoadHtml(filename, fileContent);
            //2. access dom

            WebDocument webdoc = easeViewport.GetHtmlDom();
            var         div_a  = webdoc.GetElementById("a");

            div_a.AddChild("div", div =>
            {
                div.AddChild("div", div_1 =>
                {
                    div_1.SetAttribute("style", "font:10pt tahoma");
                    div_1.AddChild("span", span =>
                    {
                        span.AddTextContent("test1");
                    });
                    div_1.AddChild("span", span =>
                    {
                        span.AddTextContent("test2");
                    });
                });
            });
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //1.init html
            var html = "<html><body><div id=\"a\">AAA</div></body></html>";

            easeViewport.LoadHtmlString("", html);
            //2. access dom

            WebDocument webdoc = easeViewport.GetHtmlDom();
            var         div_a  = webdoc.GetElementById("a");

            div_a.AddChild("div", div =>
            {
                div.AddChild("div", div_1 =>
                {
                    div_1.SetAttribute("style", "font:10pt tahoma");
                    div_1.AddChild("span", span =>
                    {
                        span.AddTextContent("test1");
                    });
                    div_1.AddChild("span", span =>
                    {
                        span.AddTextContent("test2");
                    });
                });
            });
        }