HomePHP Tracking Parsing Errors with the Tidy Library in PHP 5
Tracking Parsing Errors with the Tidy Library in PHP 5
Creating well-formed (X)HTML documents can be a hard-to-accomplish task, particularly for PHP developers who need to focus mainly on the data and business layers of their web applications, and not on their visual presentation modules. However, this issue can be addressed with minor hassles with the assistance of the excellent Tidy extension.
Welcome to the last tutorial of the series "Working with the Tidy library in PHP 5." As you might have guessed, this series offers a friendly guide to using the most important functions that come bundled with the Tidy library, so you can start quickly incorporating them into your own PHP applications.
Going straight to subject of this series, you'll remember that in the preceding article I showed you how to dissect and extract different parts of a given (X)HTML string (or even an (X)HTML file) for further processing. More concretely speaking, I demonstrated how to use the straightforward "tidy_get_html()," "tidy_get_head()" and "tidy_get_body()" functions, obviously included with the Tidy extension, in order to retrieve the entire content of a specific (X)HTML string, in addition to extracting its <head> and <body> sections respectively.
While it must be admitted that retrieving the distinct parts of a concrete (X)HTML string might not be the most useful task for a seasoned PHP developer, it's valid to mention here that the Tidy library comes equipped with a remarkable set of functions for breaking up a web document in its main section, in this way allowing users to parse the different nodes of the document in question in a simpler way.
All right, at this stage you've hopefully learned how to parse and fix the format of a given (X)HTML file via its specific set of Tidy functions, in addition to splitting a file into its most important pieces. So, the question that comes up is the following: what is the next step? Well, from a PHP developer's point of view, tracking all the errors that occurred when parsing a concrete (X)HTML string might be quite useful. Therefore, in this final tutorial of the series I'm going to cover some new functions bundled with the Tidy extension which are designed to show you the potential errors raised when interpreting (X)HTML data.
Now, with the preliminaries out of our way, it's time to tackle this last article of the series and learn how to handle parsing errors with the Tidy extension. Let's move on!