Beispiel #1
0
        public Document()
        {
            root = NewNode("html");
            head = NewNode("head");
            body = NewNode("body");

            root.AddChild(head);
            root.AddChild(body);
        }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();
            d   = new Document();
            css = new CSS();

            // generate example document
            {
                {                 // head
                    ElementNode title = Document.NewNode("title");
                    title.AddChild(Document.NewTextNode("my webpage"));
                    d.head.AddChild(title);
                }

                {                 //body
                    ElementNode title1 = Document.NewNode("h1");
                    title1.AddAttribute("id", "title");
                    title1.AddChild(Document.NewTextNode("welcome"));
                    d.body.AddChild(title1);

                    ElementNode paragraph1 = Document.NewNode("p");
                    paragraph1.AddAttribute("class", "text");
                    paragraph1.AddChild(Document.NewTextNode("welcome to my website"));
                    d.body.AddChild(paragraph1);

                    ElementNode div = Document.NewNode("div");
                    div.AddAttribute("id", "content");
                    div.AddAttribute("class", "container wrapper");
                    d.body.AddChild(div);

                    ElementNode title2 = Document.NewNode("h2");
                    title2.AddChild(Document.NewTextNode("a title in a div"));
                    div.AddChild(title2);

                    ElementNode paragraph2 = Document.NewNode("p");
                    paragraph2.AddAttribute("class", "text");
                    paragraph2.AddChild(Document.NewTextNode("a paragraph in a div"));
                    div.AddChild(paragraph2);
                }
            }

            DrawElementTree(d.root, DisplayCanvas);
        }