I figured it out, below is the solution that creates a functional XML file.
<?php
$fp = fopen('testxml.xml', 'w');
fwrite($fp, '<?xml version="1.0" encoding="UTF-8"?>');
fwrite($fp, '<gallery imagesFolder="photos/" thumbnailsFolder="thumbnails/" numRows="3">');
?>
<?php do {
$imagefile = $row_Recordset1['image1'];
$imagename = $row_Recordset1['name'];
$imageuser1 = $row_Recordset1['description'];
$imageyear = $row_Recordset1['year'];
$imageurl = $row_Recordset1['image1_link'];
fwrite($fp, '<img src="'.$imagefile.'" width="600" height="400" param="'.$imagename.' '.$imagedescription.' '.$imageyear.'" />');
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>
<?php
fwrite($fp, '</gallery>');
fclose($fp);
?>