Speed up development with full-stack environments for every branch.

Learn More

How to load a HTML document from a file with DOMDocument class [PHP]

251 Runs 946 Views 390 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php

/**
 * PHP DOM module
 * Loading a HTML document from a file with DOMDocument class
 * 
 */

//create a new DOMDocument instance
$doc = new DOMDocument();
//loading a HTML file
$doc->loadHTMLFile('test.html');

//format the output for nice display
$doc->formatOutput = true;

//to see the full output of the document 
echo '<pre>' . htmlentities($doc->saveHTML(), ENT_COMPAT | ENT_HTML401, "ISO-8859-1") . '</pre>';
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).