public static function fromHTML($html, $url = null)
    {
        if ($html instanceof MessageInterface) {
            $message = $html;
            $html    = $message->getBody() . '';

            if (!isset($url) && $message instanceof RequestInterface) {
                $url = $message->getUri() . '';
            }
        }

        $index_time = microtime(true);
        if (isset(self::$_mockup_class)) {
            $doc = new self::$_mockup_class($html, false);
        } else {
            $doc = new self($html, false);
        }
        if ($url) {
            $doc->location($url);
        }
        if (!empty($message)) {
            $doc->message     = $message;
            $doc->headers     = $message->getHeaders();
            $doc->source_type = 'message';

            if (!empty(self::$last_http_result) && self::$last_http_result->response === $message) {
                self::$last_http_result->body = $html;
            }
        }
        $doc->index();
        $index_time      = microtime(true) - $index_time;
        $doc->index_time = $index_time * 1000;
        return $doc;
    }
public static function fromHTML($html, $url = null)
    {
        if ($html instanceof MessageInterface) {
            $message = $html;
            $html    = $message->getBody() . '';

            if (!isset($url) && $message instanceof RequestInterface) {
                $url = $message->getUri() . '';
            }
        }

        $index_time = microtime(true);
        if (isset(self::$_mockup_class)) {
            $doc = new self::$_mockup_class($html, false);
        } else {
            $doc = new self($html, false);
        }
        if ($url) {
            $doc->location($url);
        }
        if (!empty($message)) {
            $doc->message     = $message;
            $doc->headers     = $message->getHeaders();
            $doc->source_type = 'message';

            if (!empty(self::$last_http_result) && self::$last_http_result->response === $message) {
                self::$last_http_result->body = $html;
            }
        }
        $doc->index();
        $index_time      = microtime(true) - $index_time;
        $doc->index_time = $index_time * 1000;
        return $doc;
    }
public static function fromHTML ( $ html , $ url = null ) { if ( $ html instanceof MessageInterface ) { $ message = $ html ; $ html = $ message -> getBody ( ) . '' ; if ( ! isset ( $ url ) && $ message instanceof RequestInterface ) { $ url = $ message -> getUri ( ) . '' ; } } $ index_time = microtime ( true ) ; if ( isset ( self :: $ _mockup_class ) ) { $ doc = new self :: $ _mockup_class ( $ html , false ) ; } else { $ doc = new self ( $ html , false ) ; } if ( $ url ) { $ doc -> location ( $ url ) ; } if ( ! empty ( $ message ) ) { $ doc -> message = $ message ; $ doc -> headers = $ message -> getHeaders ( ) ; $ doc -> source_type = 'message' ; if ( ! empty ( self :: $ last_http_result ) && self :: $ last_http_result -> response === $ message ) { self :: $ last_http_result -> body = $ html ; } } $ doc -> index ( ) ; $ index_time = microtime ( true ) - $ index_time ; $ doc -> index_time = $ index_time * 1000 ; return $ doc ; }
Parse an HTML string.

@param  string|Psr\Http\Message\MessageInterface $html  - source of some HTML document
@param  string                                   $url   - OPTIONAL location of the document. Used for relative URLs inside the document.
@return hQuery                                   $doc
Parse an HTML string .