Converting a JSON tree to XML
JSON and XML both describe hierarchical data, but they do not map onto each other perfectly. JSON has arrays, numbers, booleans and null as distinct types. XML has elements, attributes and text, and everything is a string.
The conversion here takes the common, predictable approach: object keys become element names, array items repeat the element, scalars become text content, and null becomes an empty element. Nothing is turned into an attribute, because JSON gives no signal about which values were meant to be attributes.
Where you still need XML
SOAP web services, RSS and Atom feeds, sitemaps, office document formats and a great deal of enterprise and government integration all speak XML. If you are producing data for one of those and your source is JSON, this is the bridge.
Going the other direction, use XML to JSON. For an XML sitemap specifically, the sitemap generator produces the exact format search engines expect.