Para crear un archivo XML con SimpleXML o DOM es bien simple. Te doy un ejemplo con SimpleXML
Código PHP:
Ver original<?php
$xml = new SimpleXMLElement("<foo></foo>");
$xml->addAttribute('fooattr', 'value of fooattr');
$bar = $xml->addChild('bar');
$bar->addAttribute('barattr', 'value of barattr');
$baz = $xml->addChild('baz');
$candy = $baz->addChild('candy', 'value of candy');
$candy->addAttribute('candyattr', 'value of candyattr');
$fruits = $baz->addChild('fruits', 'value of fruits');
$fruits->addAttribute('fruitsattr', 'value of fruitsattr');
$vegetable = $baz->addChild('vegetable', 'value of vegetable');
$vegetable->addAttribute('vegetableattr', 'value of vegetableattr');
header('Content-type: text/xml; charset=utf-8'); echo $xml->asXML();