Tuesday, October 20, 2009

Tool Of The Day: PHP Simple HTML DOM Parser

I needed to update some code that was responsible for tweaking the output of HTML content. What no doubt started off as a few quick regular expression replacements turned into a bowl of spaghetti code.

Today, I was lucky enough to find the PHP Simple HTML DOM Parser, which allowed me to untangle the mess. Rather than working with HTML as a string, it does as the name suggests and allows you to treat it as a DOM tree. You can access the elements using CSS selectors like you would in jquery.

The API is simple, and the underlying parser is tolerant of HTML errors.

If you're working with PHP and HTML this is a must have tool in your toolbox.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails