a .xml file is static, just like .html or .txt so it won't process embedded PHP
create listings.php instead, which outputs xml (and serves the appropriate header), or
configure your server (e.g Apache) to parse .xml with PHP, which would allow you to embed PHP in the file (this will affect all .xml files), or
have a separate PHP script regularly write the static listings.xml file (e.g triggered to run every 10 minutes by a cron job). This is probably a good idea if the file is accessed a lot more than it changes.
As for actually creating the dynamic XML doc, you could use the DOM Extension, or just dynamically output strings. Using DOM is more complex, but more reliable.