简体   繁体   English

Java中的HTML验证

[英]HTML validation in Java

I try to write a HTML validator. 我尝试编写一个HTML验证程序。 At this time I considered the best way is to use a DTD File, because the Validator should complain, if interactive things, like JavaScript are used. 目前,我认为最好的方法是使用DTD文件,因为如果使用了JavaScript之类的交互功能,验证器会抱怨。 Does anyone know a way, how i can validate a HTML file against a DTD file in Java? 有谁知道一种方法,如何在Java中针对DTD文件验证HTML文件? Are there ways with native librarys? 本地图书馆有办法吗? I'm also satisfied with external libraries. 我对外部库也很满意。 thanks in advance 提前致谢

Word of advice: you cannot really identify all javascript in HTML with accuracy. 忠告:您无法真正准确地识别HTML中的所有JavaScript。 How precise do you have to be about it? 您必须精确到什么程度? You can have javascript in event handlers, inline and in many other places. 您可以在事件处理程序,内联和许多其他地方使用javascript。

If you are satisfied with non-strict parsing, I suggest NejoHtml and TagSoup 如果您对非严格解析感到满意,建议您使用NejoHtmlTagSoup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM