I export the XML tree in the DOM, then save that text as an XML document. I used AngularJS for the web application, and JavaScript to create the XML feed.
There is often confusion about sitemaps, how they are implemented, and how they can be best leveraged with search engine tools for search engine optimization (SEO).