Using the tidy markup parser
In PHP 5 Tidy also provides a number of object-oriented constructs for document parsing and screen-scraping.

Using the tidy parser is simple
A number of functions are provided to allow you to "jump into" a particular major section of the document and begin traversing from there: