This is not an .htaccess or PHP.ini issue, this is an issue with the file system that you are using. If you have FTP access to the folder where you are trying to write the file, which should only contain files and not executable code, you would want to change the permissions of that folder to world writable.
You can test if the directory can be written to by using the following:
PHP Code:
if (is_writable('directory/')) {
$sxe->asXML('directory/morgy.xml') or die('can\'t write the file');
} else {
echo 'Permissions insufficient to write here.';
}
And of course at the end of the script you would have
PHP Code:
function die($msg) { echo ($msg); exit();}
Assuming you are using a Linux server, you should chmod the folder you are writing to to 774 provided the folder only contains text files.