Exemple #1
0
        /// <summary>
        /// Method which determines if the tag needs alternative closing, like <img />, <br />, <hr />
        /// </summary>
        /// <param name="element">Element to check</param>
        /// <returns>True if empty element, otherwise false</returns>
        private bool IsEmptyElement(XHTMLElement element)
        {
            //Check if element has childs, if not it's empty
            if (element.GetChildren().Count == 0 && !element.IsGenerated())
            {
                return(true);
            }

            //Generated elements like html in empty file should not be shortened in ending
            if (element.IsGenerated())
            {
                return(false);
            }

            //Some elements are always empty
            String[] xhtmlEmptyTags = Enum.GetNames(typeof(EmptyXHTMLElement));
            String   tag            = element.GetTag();

            foreach (String item in xhtmlEmptyTags)
            {
                if (item.Equals(tag.ToUpper()))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Writes the complete tree to an HTML file
 /// </summary>
 public void WriteStream()
 {
     //If root is generated, no doctype, otherwise write a doctype header
     if (!Root.IsGenerated() && !IsEmptyElement(Root))
     {
         //Write doctype before starting document
         WriteDocType(DocTyping);
     }
     Visit(Root);
 }
        /// <summary>
        /// Method which determines if the tag needs alternative closing, like <img />, <br />, <hr />
        /// </summary>
        /// <param name="element">Element to check</param>
        /// <returns>True if empty element, otherwise false</returns>
        private bool IsEmptyElement(XHTMLElement element)
        {
            //Check if element has childs, if not it's empty
            if (element.GetChildren().Count == 0 && !element.IsGenerated())
            {
                return true;
            }

            //Generated elements like html in empty file should not be shortened in ending
            if (element.IsGenerated())
            {
                return false;
            }

            //Some elements are always empty
            String[] xhtmlEmptyTags = Enum.GetNames(typeof(EmptyXHTMLElement));
            String tag = element.GetTag();
            foreach (String item in xhtmlEmptyTags)
            {
                if (item.Equals(tag.ToUpper()))
                {
                    return true;
                }
            }
            return false;
        }