Load XML from a file and create DOMDocument in PHP

Description

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

Example


// w ww  .  jav  a2 s  . com
<?php
$doc = new DOMDocument();
$doc->load('test.xml');
echo $doc->saveXML();
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    XML »




DOM
SimpleXML
SimpleXMLElement
XML Parser