QueryPath::withHTML PHP Method

withHTML() public static method

public static withHTML ( $source = null, $selector = null, $options = [] )
    public static function withHTML($source = null, $selector = null, $options = array())
    {
        // Need a way to force an HTML parse instead of an XML parse when the
        // doctype is XHTML, since many XHTML documents are not valid XML
        // (because of coding errors, not by design).
        $options += array('ignore_parser_warnings' => true, 'convert_to_encoding' => 'ISO-8859-1', 'convert_from_encoding' => 'auto', 'use_parser' => 'html');
        return @self::with($source, $selector, $options);
    }

Usage Example

Example #1
0
 public static function htmlqp($document = NULL, $selector = NULL, $options = array())
 {
     self::$qp = false;
     //	I copied and modified the default options from the htmlqp method to provide a custom version for Amslib
     //	NOTE: Hmm....I'm not 100% sure this will work in all circumstances....
     $document = iconv("ISO8859-1", "UTF-8", $document);
     //	NOTE: see output buffer trick comment in qp()
     ob_start();
     self::$qp = QueryPath::withHTML($document, $selector, $options);
     $warnings = ob_get_clean();
     if (strlen($warnings)) {
         Amslib_Debug::log("FAILED TO OBTAIN CLEAN OUTPUT WHEN PROCESSING HTML: error = ", $warnings);
     }
     return self::$qp;
 }
All Usage Examples Of QueryPath::withHTML