开发者

Is there a pure Javascript X/HTML validator? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or fin开发者_高级运维d a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this question

I want to know if there's an existing Javascript library for validating HTML, preferably not one that relies on a web API.

The closest I've found to this is John Resig's HTML parser, but that seems to be more about fixing HTML and converting it to XML.

So is there something out there already? And if not, how difficult (and lengthy) would it be to adapt John Resig's parser?


No, there isn't one. However I am writing one: https://github.com/peterjwest/html_validator


You can't validate HTML with Javascript, because Javascript is loaded from within the HTML, which means the HTML is already rendered by the browser, which means all you can see with Javascript is the dom tree. The dom tree is built by the browser, but renders with and 'fixes' invalidations.

In short: What you need to validate HTML, is the HTML source. Javascript has access to the DOM, but not to the source.

edit
And immediately after posting, I'm thinking... You don't mean validating its own page =) You just want to validate a string with a javascript... So ignore this =)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜