Output of the code as on Mozilla FF
<?php
$dom = new DOMDocument('1.0','UTF-8');
$dom->formatOutput = true;
$root = $dom->createElement('student');
$dom->appendChild($root);
$result = $dom->createElement('result');
$root->appendChild($result);
$result->setAttribute('id', 1);
$result->appendChild( $dom->createElement('name', 'Opal Kole') );
$result->appendChild( $dom->createElement('sgpa', '8.1') );
$result->appendChild( $dom->createElement('cgpa', '8.4') );
echo '<xmp>'. $dom->saveXML() .'</xmp>';
$dom->save('menu.xml') or die('XML Create Error');
?>
I am using PHP 4+ on my server , I have already checked on the expected solutions on the Stack overflow but none of that works. Thanks in advance
Its the error of permission in the file. The php file and the xml must have 0777 permission.
This code works fine for me. May be you should try to check your permission for write in the folder since the code is ok.