I used below code to generate sitemap
$xml = new SimpleXMLElement('<urlset/>');
$track = $xml->addChild('url');
$track->addChild('loc', $url);
Header('Content-type: text/xml');
print($xml->asXML());
and Result for above code is
<?xml version="1.0"?>
<urlset>
<url>
<loc>http://domain.com</loc>
</url>
</urlset>
But I want the result to be like below
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://domain.com</loc>
</url>
</urlset>
How to add the extra attributes like xmlns , encoding etc..