예제 #1
0
        private HtmlNode CreateHtmlTOC(XElement toc)
        {
            TOCElements ele    = new TOCElements(toc);
            string      source = GetSource(ele.Source);

            HtmlNode TopNode = Tocdocument.CreateElement("p");
            string   style   = "margin:0; padding: 0;" + "text-indent:" + indent.ToString() + "pt;";

            TopNode.Attributes.Add("style", style);

            HtmlNode node = Tocdocument.CreateElement("a");

            node.Attributes.Add("href", source);

            HtmlNode text = HtmlTextNode.CreateNode(ele.Text);

            if (text == null)
            {
                return(null);
            }

            node.AppendChild(text);
            TopNode.AppendChild(node);

            if (toc.Descendants(ns + "navPoint").Count() > 0)
            {
                indent = indent + 15;

                foreach (XElement item in toc.Descendants(ns + "navPoint"))
                {
                    HtmlNode itemNode = CreateHtmlTOC(item);
                    if (itemNode != null)
                    {
                        TopNode.AppendChild(itemNode);
                    }
                }
            }

            return(TopNode);
        }
        private HtmlNode CreateHtmlTOC(XElement toc)
        {
            TOCElements ele = new TOCElements(toc);
            string source = GetSource(ele.Source);

            HtmlNode TopNode = Tocdocument.CreateElement("p");
            string style = "margin:0; padding: 0;" + "text-indent:" + indent.ToString() + "pt;";
            TopNode.Attributes.Add("style", style);

            HtmlNode node = Tocdocument.CreateElement("a");
            node.Attributes.Add("href", source);

            HtmlNode text = HtmlTextNode.CreateNode(ele.Text);
            if (text == null)
                return null;

            node.AppendChild(text);
            TopNode.AppendChild(node);

            if (toc.Descendants(ns + "navPoint").Count() > 0)
            {
                indent = indent + 15;

                foreach (XElement item in toc.Descendants(ns + "navPoint"))
                {
                    HtmlNode itemNode = CreateHtmlTOC(item);
                    if (itemNode != null)
                    {
                        TopNode.AppendChild(itemNode);
                    }
                }
            }

            return TopNode;
        }