ciao!

vorrei creare un file xml da php con SimpleXMLElement, ma ottengo questo errore:
codice:
Warning:  SimpleXMLElement::__construct(): Entity: line 1: parser error : Premature end of data in tag sitemapindex line 1 in xml_sitemap.php on line 104

Fatal error:  Uncaught exception 'Exception' with message 'String  could not be parsed as XML' in  /web/htdocs/www.mattepuffo.com/home/blog/admin/xml_sitemap.php:104 Stack trace: #0 /web/htdocs/www.mattepuffo.com/home/blog/admin/xml_sitemap.php(104):  SimpleXMLElement->__construct('<?xml version="...') #1 {main}   thrown in xml_sitemap.php on line 104
questo il codice:
Codice PHP:
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.9">');
$url = $xml->addChild('sitemap');
foreach ($arrIndex as $key => $val) {
    $url->addChild('loc', $val['loc']);
    $url->addChild('lastmod', $val['lastmod']);
}
qualche idea??