JSON to XML logic