Home > Uncategorized > PHP : Read XML File with simplexml_load_file Test Script

PHP : Read XML File with simplexml_load_file Test Script

December 16th, 2009 Leave a comment Go to comments


<?php
/* create test.xml from following lines
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Fred</to>
<from>Joe</from>
<heading>Reminder</heading>
<body>Meeting Tomorrow</body>
</note>
*/
error_reporting(E_ALL);
if (!function_exists('simplexml_load_file')) exit('<br>function does not exist');
if (file_exists('test.xml'))
{
$xml = @simplexml_load_file('test.xml');
echo "<pre>";var_dump($xml);
}
else { exit('<br>Error could not locate XML file'); }
?>

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.