probabilmente l'xml che produce non è ben formato (forse ci sono dei caratteri che vanno escapizzati).
Prova a far stampare in un file di testo l'output e non a video e sopratutto per generare correttamente una stringa XML è obbligatorio utilizzare i metodi dell'oggeto XML e non concatenare stringhe (avrai sempre problemi di escape dei caratteri).
Ecco un esempio di utilizzo del DOM XML di PHP:
codice:
$domain = "http://www.miodominio.com/";
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$urlset = $doc->createElement("urlset");
$urlset->setAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
$urlset->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
$urlset->setAttribute("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd");
$url = $doc->createElement("url");
$loc = $doc->createElement("loc");
$lastmod = $doc->createElement("lastmod");
$changefreq = $doc->createElement("changefreq");
$priority = $doc->createElement("priority");
.... ecc