Make wordpress generate a custom XML file(not a sitemap) that is updated only when new content is posted?

Hmm… not sure if there are any WordPress-specific functions for creating files. There’s wp_handle_upload, but I’m not sure how you’d use it in this context.

Depending on your server configuration, you can probably just use fopen and fwrite to do this.

Keep the code you’re currently using (with your custom loops…I’m assuming they contain the XML markup you want), but have it build the output as a string. Then save that string into a file. Something like:

// Build your file contents as a string
$file_contents="<?xml version="1.0" ?><yourroot><item>some content</item></yourroot></xml>";

// Open or create a file (this does it in the same dir as the script)
$my_file = fopen("myfile.xml", "w");

// Write the string's contents into that file
fwrite($my_file, $file_contents);

// Close 'er up
fclose($my_file);

Of course, this all depends on your server config and permissions. Maybe someone has a better solution that only requires native WP functions.