You are here

public function HTML5::load in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/masterminds/html5/src/HTML5.php \Masterminds\HTML5::load()

Load and parse an HTML file.

This will apply the HTML5 parser, which is tolerant of many varieties of HTML, including XHTML 1, HTML 4, and well-formed HTML 3. Note that in these cases, not all of the old data will be preserved. For example, XHTML's XML declaration will be removed.

The rules governing parsing are set out in the HTML 5 spec.

Parameters

string $file: The path to the file to parse. If this is a resource, it is assumed to be an open stream whose pointer is set to the first byte of input.

array $options: Configuration options when parsing the HTML

Return value

\DOMDocument A DOM document. These object type is defined by the libxml library, and should have been included with your version of PHP.

1 call to HTML5::load()
HTML5::loadHTMLFile in vendor/masterminds/html5/src/HTML5.php
Convenience function to load an HTML file.

File

vendor/masterminds/html5/src/HTML5.php, line 68

Class

HTML5
This class offers convenience methods for parsing and serializing HTML5. It is roughly designed to mirror the \DOMDocument class that is provided with most versions of PHP.

Namespace

Masterminds

Code

public function load($file, array $options = array()) {

  // Handle the case where file is a resource.
  if (is_resource($file)) {

    // FIXME: We need a StreamInputStream class.
    return $this
      ->loadHTML(stream_get_contents($file), $options);
  }
  $input = new FileInputStream($file);
  return $this
    ->parse($input, $options);
}