use Drupal\Component\Utility\Html; $html = ''; $dom = Html::load($html);Hello world
use Drupal\Component\Utility\Html; $filename = '/path/to/my/file.html'; $html = file_get_contents($filename); $dom = Html::load($html);In the above examples, we used the Html::load() method to load HTML from a string and from a file, respectively. The resulting \DOMDocument object can be further manipulated with functions from the PHP DOM extension. Overall, Php Drupal.Component.Utility Html load is a useful package library for working with HTML in Drupal 8.