Skip to content

Instantly share code, notes, and snippets.

@jcsalterego
Created December 16, 2008 22:37
Show Gist options
  • Save jcsalterego/36846 to your computer and use it in GitHub Desktop.
Save jcsalterego/36846 to your computer and use it in GitHub Desktop.
<?php
$xml = new SimpleXMLElement('<sitemap></sitemap>');
foreach ($pages as $page)
$page_xml = $xml->addChild('page');
$page_xml->addChild('loc', $page['loc']);
$page_xml->addChild('priority', $page['priority']);
$page_xml->addChild('changefreq', $page['changefreq']);
}
$doc = new DOMDocument('1.0','utf-8');
$doc->formatOutput = true;
$domnode = dom_import_simplexml($xml);
$domnode = $doc->importNode($domnode, true);
$domnode = $doc->appendChild($domnode);
echo $doc->saveXML();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment