My phpinfo() shows that DOM is fully enabled, yet when i create a php file called 'test.php' and place it in the htdocs folder, i get the code itself echoed on the screen and no xml file is generated.
Can you please advise i f i am missing something with the setup, or i should add something to the header of this code to work?
- Code: Select all
<?php
$doc = new_xmldoc('1.0');
$root = $xdoc->add_root('members');
$member = $root->new_child('member','');
$member->new_child('lastName','John');
$member->new_child('firstName','Adams');
$member->new_child('contribution','3400');
$member = $root->new_child('member','');
$member->new_child('lastName','Debra');
$member->new_child('firstName','Hones');
$member->new_child('contribution','2400');
$member = $root->new_child('member','');
$member->new_child('lastName','Jake');
$member->new_child('firstName','Tudor');
$member->new_child('contribution','1200');
$fp = @fopen('members.xml','w');
if(!$fp) {
die('Error cannot create XML file');
}
fwrite($fp,$doc->dumpmem());
fclose($fp);
?>