Exemplo n.º 1
0
        private void CheckElements(System.Xml.XmlDocument doc, XHtmlMode mode)
        {
            if (mode == XHtmlMode.None)
            {
                return;
            }

            //Select all the nodes
            System.Xml.XmlNodeList list = doc.SelectNodes("//*");
            foreach (System.Xml.XmlElement element in list)
            {
                if (mode == XHtmlMode.StrictValidation)
                {
                    CheckStrictValidation(element);
                }
                else if (mode == XHtmlMode.BasicValidation)
                {
                    CheckBasicValidation(element);
                }
                else
                {
                    throw new ArgumentException("XHtmlMode not supported", "mode");
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Check if the html is a valid text using the XML document validator.
 /// </summary>
 public bool IsValid(XHtmlMode mode)
 {
     try
     {
         this.CheckElements(this._xmlDoc, mode);
         return(true);
     }
     catch (Exception ex) { log.Error("Exception occur:", ex); }
     return(false);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Check if the html is a valid text using the XML document validator.
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="error"></param>
        public bool IsValid(XHtmlMode mode, out Exception error)
        {
            try
            {
                CheckElements(mDoc, mode);

                error = null;
                return(true);
            }
            catch (Exception ex)
            {
                error = ex;
                return(false);
            }
        }
Exemplo n.º 4
0
        private void CheckElements(System.Xml.XmlDocument doc, XHtmlMode mode)
        {
            if (mode == XHtmlMode.None)
                return;

            //Select all the nodes
            System.Xml.XmlNodeList list = doc.SelectNodes("//*");
            foreach (System.Xml.XmlElement element in list)
            {
                if (mode == XHtmlMode.StrictValidation)
                    CheckStrictValidation(element);
                else if (mode == XHtmlMode.BasicValidation)
                    CheckBasicValidation(element);
                else
                    throw new ArgumentException("XHtmlMode not supported", "mode");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Check if the html is a valid text using the XML document validator.
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="error"></param>
        public bool IsValid(XHtmlMode mode, out Exception error)
        {
            try
            {
                CheckElements(mDoc, mode);

                error = null;
                return true;
            }
            catch (Exception ex)
            {
                error = ex;
                return false;
            }
        }