Ditch the DOM
Use SimpleXMLElement over DOM.
Refactor Sitemap to use SimpleXML.
Sitemap example.