Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Parser validate tags

I need html parse which have capability to identify error in generated html and if tags are not closed then close it and return the valid html.

More detail: i am getting data from database and break that record to show partial detail on my website to click on more button then show complete content. After breaking string then validate.

I have already used Html Agility Pack but i am new to use it, if this library solve my issue then guide me how (tutorial) or suggest me another library.

like image 631
Xulfee Avatar asked Nov 06 '22 03:11

Xulfee


2 Answers

I don't think such a library does exist. The problem is, that some libraries can indeed identify errors in your HTML but they cant fix them for you.

I think using the W3C validator as a service is the best starting point here. There's an open source library which uses the API of the W3C validator to validate a document and gives you the response if it is valid or not as well as errors and warnings. I would start with this and then go on from there.

  • W3C Markup Validator library in C#
like image 191
Martin Buberl Avatar answered Nov 15 '22 00:11

Martin Buberl


Here are a couple of validation programs from the World Wide Web Consortium, the W3C:

Windows: http://validator.w3.org/docs/install_win.html

UNIX / Linux: http://validator.w3.org/docs/install.html

You can also use their web services to validate your CSS, HTML, XML, XHTML, JavaScript and many other web technologies. The W3C is one of the overseers of keeping the Internet highly interoperable and internet devices somewhat compatible with each other.

like image 40
DoctorLouie Avatar answered Nov 15 '22 01:11

DoctorLouie