2

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..

Anisha Virat
  • 259
  • 4
  • 16
  • I did not get any answer...please reopen this question – Anisha Virat Aug 11 '13 at 12:29
  • No. I won't reopen the question. The answer is in the given dupe and you are supposed to do thorough research before asking questions as well. So please use the search function before asking questions that have been asked and answered before. It's not optional. – Gordon Aug 11 '13 at 12:30

0 Answers0