Perhaps this is a Rewrite issue??
RewriteRule ^sitemap.xml(.*)$ /sitemap.php?$1
with sitemap.php being the name of the php file that your code is saved within.
Also, and unrelated, you have within all of the loc paths:
filename.php.php
Pretty sure you will want to drop that .php you have hardcoded.