Yes, there are mainly two ways to do this:
1) If you only need one XML file with PHP in it, just save it as a normal PHP file (.php), but put:
header('Content-type: text/xml');
at the top of the file. This will cause any clients who access the script to handle it as a normal XML file.
2) If you need multiple XML files with PHP, you may want to make PHP handle all .xml files as PHP code. Just add the following lines to the .htaccess file:
RemoveHandler .xml
AddType application/x-httpd-php .php .xml
Now write your PHP code as you normally would, but just be sure to generate an XML file instead of a HTML file. You might want to take a look at SimpleXML [ http://php.net/simplexml ], which is very helpful when it comes to generating XML.