Validate your XML file while loading in PHP

Description

The following code shows how to validate your XML file while loading.

Example


//from  w w w  .  jav a  2s . com


<?php
$dom = new DOMDocument;
$dom->validateOnParse = true;
$dom->Load('test.xml');

echo $dom->saveXML();
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    XML »




DOM
SimpleXML
SimpleXMLElement
XML Parser