Load HTML from a file and create DOMDocument in PHP

Description

The following code shows how to load HTML from a file and create DOMDocument.

Example


/* w w w . ja va  2 s  .c o m*/

<?php
$doc = new DOMDocument();
$doc->loadHTMLFile("filename.html");
echo $doc->saveHTML();
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    XML »




DOM
SimpleXML
SimpleXMLElement
XML Parser