FluentDOM
[ class tree: FluentDOM ] [ index: FluentDOM ] [ all elements ]

Source for file FileHTML.php

Documentation is available at FileHTML.php

  1. <?php
  2. /**
  3. * Load FluentDOM from local HTML file
  4. *
  5. @version $Id: FileHTML.php 431 2010-03-29 20:42:04Z subjective $
  6. @license http://www.opensource.org/licenses/mit-license.php The MIT License
  7. @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert
  8. *
  9. @package FluentDOM
  10. @subpackage Loaders
  11. */
  12.  
  13. /**
  14. * include interface
  15. */
  16. require_once(dirname(__FILE__).'/../Loader.php');
  17.  
  18. /**
  19. * Load FluentDOM from HTML file
  20. *
  21. @package FluentDOM
  22. @subpackage Loaders
  23. */
  24. class FluentDOMLoaderFileHTML implements FluentDOMLoader {
  25.  
  26.   /**
  27.   * load DOMDocument from local HTML file
  28.   *
  29.   * @param string $source filename
  30.   * @param string $contentType 
  31.   * @return DOMDocument|FALSE
  32.   */
  33.   public function load($source$contentType{
  34.     if (is_string($source&&
  35.         FALSE === strpos($source'<'&&
  36.         $contentType == 'text/html'{
  37.  
  38.       if (!file_exists($source)) {
  39.         throw new InvalidArgumentException('File not found: '$source);
  40.       }
  41.  
  42.       $dom new DOMDocument();
  43.       $errorSetting libxml_use_internal_errors(TRUE);
  44.       libxml_clear_errors();
  45.       $dom->loadHTMLFile($source);
  46.       libxml_clear_errors();
  47.       libxml_use_internal_errors($errorSetting);
  48.       return $dom;
  49.     }
  50.     return FALSE;
  51.   }
  52. }
  53.  
  54. ?>

Documentation generated on Sun, 26 Sep 2010 01:00:38 +0200 by phpDocumentor 1.4.3