How to validate HTML from Java?

后端 未结 2 990
长情又很酷
长情又很酷 2020-12-10 12:52

What is a fast and simple way to validate HTML from Java? I’m looking for an open-source/PD class (or set of classes) that describes the various properties of the 100-odd H

2条回答
  •  失恋的感觉
    2020-12-10 13:35

    If you want to verify certain tags follow certain specifications, there seems to be no end of Java based HTML parsers:

    Open Source HTML Parsers in Java

    In other words, you could parse you HTML, and then inspect the resulting document for the tags you were looking for and determine if they meet the specifications you require. If they don't you could then just throw an error.

    I don't think you'll find a HTML analysis tool which was written with exactly your requirements in mind, mostly because those requirements haven't been voiced and are probably a bit nebulous.

    If the parser doesn't do what you want out of the box, at least this list is open source, so you can hack the parser as long as you publish your changes.

提交回复
热议问题