Anyhow, if you poke around in the wp-admin/export.php page, you'll notice that it calls a function
export_wp
(which is defined at wp-admin/includes/export.php). And voila! Amazingly that's all you need!It'll spit out the xml to stdout so you'll want to grab that buffer! See the code below to generally see how I did things.
Simple. Very useful! Cheers!
include 'wp-config.php';
include 'wp-admin/includes/export.php';
ob_start();
export_wp();
$file = ob_get_contents();
ob_end_clean();
$fh = fopen("wordpress-" . date('Y-m-d') . ".xml", 'w');
fwrite($fh, $file);
fclose($fh);