Sunday, December 27, 2009

HTML parser for JavaScript

I needed an HTML parser for one of my projects. As I am using exclusively JavaScript lately (and loving it) I searched for a JavaScript solution. Envjs looked interesting but the messy source code (and global namespace pollution) was discomforting. Finally I decided to package Java HTML5 parser used in Envjs for NarwhalNarwhal.

The tricky part was to make the parser compatible with Sizzle but I am happy to report that they both work great together now. You can find the source code for the package here.


4 comments:

Roberto Saccon said...

Cool ! George, your stuff rocks ! Does your HTML5 parser / sizzle package allow to do DOM-like queries at serverside as in the browser ? That would open the doors to a PURE-like template language, where the template is pure HTML, and it would run on server and browser.

dionyziz said...

If you're using Javascript within a browser, there is an excellent HTML parsing library that you can use, which has been tested and works very well, and is actually the most used HTML parsing library on the web today: The browser itself.

George Moschovitis said...

Roberto, yeah it allows DOM-like queries. For example you can use jQuery or Sizzle to play with the DOM

George Moschovitis said...

dionyziz, the parser is intended for the server side. it emulates the browser so you can play with the DOM or use Sizzle or something. It is intended for web scraping etc...

Post a Comment