Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HTML5.php

function 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|resource $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 65

Class

HTML5
This class offers convenience methods for parsing and serializing HTML5. It is roughly designed to mirror the \DOMDocument native class.

Namespace

Masterminds

Code

public function load($file, array $options = array()) {
    // Handle the case where file is a resource.
    if (is_resource($file)) {
        return $this->parse(stream_get_contents($file), $options);
    }
    return $this->parse(file_get_contents($file), $options);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal