예제 #1
0
        static void Main(string[] args)
        {
            //*********************************//
            //**Example of use of the library**//
            //*********************************//

            //Not found ourl
            //HTMLValidate htmlValidate = new HTMLValidate("http://www.walidator.org");
            //Valid XHTML Basic 1.0 URL
            HTMLValidate htmlValidate = new HTMLValidate("http://mariaefm.net/docs_pfc/xhtml_10.html");

            //Invalid URL
            //HTMLValidate htmlValidate = new HTMLValidate("http://www.google.es");

            try
            {
                if (!htmlValidate.Validate(HTMLValidate.emptyEncoding, HTMLValidate.emptyDoctype))
                {
                    Console.WriteLine("Invalid Markup validation of the document");
                }
                else
                {
                    Console.WriteLine("Valid Markup validation of the document");
                }
            }
            catch (ControlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.errorTimeStamp.ToString());
            }

            try
            {
                if (!htmlValidate.ValidationOfEncoding(HTMLValidate.UTF8))
                {
                    Console.WriteLine("This document is NOT a valid utf-8 document");
                    foreach (Fault element in htmlValidate.faults)
                    {
                        if (element.messageid == "fatal_byte_error")
                        {
                            Console.WriteLine(element.ToString());
                        }
                    }
                }
                else
                {
                    Console.WriteLine("This document is a valid utf-8 document");
                }
            }
            catch (ControlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.errorTimeStamp.ToString());
            }

            try
            {
                if (!htmlValidate.ValidationOfDoctype(HTMLValidate.XHTML_BASIC_10))
                {
                    Console.WriteLine("This document is NOT a valid html document");
                    foreach (Error element in htmlValidate.errors)
                    {
                        Console.WriteLine(element.ToString());
                    }
                    htmlValidate.printErrorsToFile();

                    foreach (WarningPotentialIssue warningPotentialIssue in htmlValidate.warningPotentialIssues)
                    {
                        Console.WriteLine(warningPotentialIssue.ToString());
                    }

                    foreach (Warning warning in htmlValidate.warnings)
                    {
                        Console.WriteLine(warning.ToString());
                    }
                    htmlValidate.printWarningsToFile();
                }
                else
                {
                    Console.WriteLine("This document is a valid html document");
                }
            }
            catch (ControlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.errorTimeStamp.ToString());
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            //*********************************//
            //**Example of use of the library**//
            //*********************************//

            //Not found ourl
            //HTMLValidate htmlValidate = new HTMLValidate("http://www.walidator.org");
            //Valid XHTML Basic 1.0 URL
            HTMLValidate htmlValidate = new HTMLValidate("http://mariaefm.net/docs_pfc/xhtml_10.html");
            //Invalid URL
            //HTMLValidate htmlValidate = new HTMLValidate("http://www.google.es");

            try
            {
                if (!htmlValidate.Validate(HTMLValidate.emptyEncoding, HTMLValidate.emptyDoctype))
                {
                    Console.WriteLine("Invalid Markup validation of the document");
                }
                else
                {
                    Console.WriteLine("Valid Markup validation of the document");
                }
            }
            catch (ControlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.errorTimeStamp.ToString());
            }

            try
            {
                if (!htmlValidate.ValidationOfEncoding(HTMLValidate.UTF8))
                {
                    Console.WriteLine("This document is NOT a valid utf-8 document");
                    foreach (Fault element in htmlValidate.faults)
                    {
                        if (element.messageid == "fatal_byte_error")
                            Console.WriteLine(element.ToString());
                    }
                }
                else
                    Console.WriteLine("This document is a valid utf-8 document");
            }
            catch (ControlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.errorTimeStamp.ToString());
            }

            try
            {
                if (!htmlValidate.ValidationOfDoctype(HTMLValidate.XHTML_BASIC_10))
                {
                    Console.WriteLine("This document is NOT a valid html document");
                    foreach (Error element in htmlValidate.errors)
                    {
                        Console.WriteLine(element.ToString());
                    }
                    htmlValidate.printErrorsToFile();

                    foreach (WarningPotentialIssue warningPotentialIssue in htmlValidate.warningPotentialIssues)
                    {
                        Console.WriteLine(warningPotentialIssue.ToString());
                    }

                    foreach (Warning warning in htmlValidate.warnings)
                    {
                        Console.WriteLine(warning.ToString());
                    }
                    htmlValidate.printWarningsToFile();
                }
                else
                    Console.WriteLine("This document is a valid html document");
            }
            catch (ControlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.errorTimeStamp.ToString());
            }
        }