PHP
  Home arrow PHP arrow Page 2 - Tracking Parsing Errors with the Tidy Library in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Tracking Parsing Errors with the Tidy Library in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2007-07-11


    Table of Contents:
  • Tracking Parsing Errors with the Tidy Library in PHP 5
  • Summarizing some Tidy library concepts
  • Using the tidy_get_error_buffer() function
  • Using the tidy_access_count(), tidy_error_count() and tidy_warning_count() functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Tracking Parsing Errors with the Tidy Library in PHP 5 - Summarizing some Tidy library concepts
    ( Page 2 of 4 )

    Before I move on, I'd first like to remind you of the most important topics treated in the preceding article of the series. This review should help you see more easily how the Tidy functions learned in that tutorial can be linked with the ones that I plan to cover in a few moments.

    Having said that, below I listed some basic examples of how to use the hopefully familiar "tidy_get_html()," "tidy_get_head()" and "tidy_get_body()" functions, which are tasked with extracting the different sections of a specified (X)HTML string. Here are the corresponding code samples; have a look at them please:

    // example on using the 'tidy_get_html()' function

    $html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html
    xmlns="http://www.w3.org/1999/xhtml"><head><title>Testing
    Tidy</title></head><body><p>Testing Tidy</p></body></html>';
    $tidy=tidy_parse_string($html);
    $htmlNode=tidy_get_html($tidy);
    echo $htmlNode->value;

    /* displays the following:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>Testing Tidy</title>
    </head>
    <body><p>Testing Tidy</p>
    </body>
    </html>
    */

    // example on using the 'tidy_get_head()' function

    $html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html
    xmlns="http://www.w3.org/1999/xhtml"><head><title>Testing
    Tidy</title></head><body><p>Testing Tidy</p></body></html>';
    $tidy=tidy_parse_string($html);
    $headNode=tidy_get_html($tidy);
    echo $headNode->value;

    /* displays the following:
    <head>
      <title>Testing Tidy</title>
    </head>
    */

    // example on using the 'tidy_get_body()' function

    $html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html
    xmlns="http://www.w3.org/1999/xhtml"><head><title>Testing
    Tidy</title></head><body><p>Testing Tidy</p></body></html>';
    $tidy=tidy_parse_string($html);
    $bodyNode=tidy_get_body($tidy);
    echo $bodyNode->value;

    /* displays the following:
    <body>
      <p>Testing Tidy</p>
    </body>
    */

    Hopefully, after studying the respective signatures for the three previous examples, you'll recall how easy it is to extract the distinct sections of a specified (X)HTML string using the functions provided by the Tidy library. Nonetheless, I believe that these functions in particular don't bear any additional discussion, since they were already covered in detail in the previous tutorial of the series.

    Therefore, it's a good time to move forward and start looking into the group of Tidy functions aimed specifically at handling all the errors that occur when parsing a concrete (X)HTML string.

    Want to see how these brand new functions will be properly implemented? Click on the link below and keep reading.



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek