Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I validate a html file with C#?

I have a C# application that receives an html file. I want to parse and validate it. On output it will return a list of errors or that my html is valid.

Has anyone any idea how can I do this?

like image 334
Jeff Norman Avatar asked Oct 04 '10 09:10

Jeff Norman


People also ask

How do I check if HTML code is correct?

The World Wide Web Consortium provide a simple online tool (https://validator.w3.org/) that automatically check your HTML code and point out any problems/errors your code might have, such as missing closing tags or missing quotes around attributes.

What tool is used to check HTML validity?

An HTML validator is a quality assurance program used to check Hypertext Markup Language ( HTML ) markup elements for syntax errors. A validator can be a useful tool for an HTML user who receives data electronically from a variety of input sources.


2 Answers

I'd run a local instance of the W3C Markup Validation service and communicate with it via the API

like image 70
Quentin Avatar answered Sep 18 '22 03:09

Quentin


You can use HTML Tidy. There is a wrapper for .NET called TidyManaged

like image 20
gcores Avatar answered Sep 20 '22 03:09

gcores