Convert a String from JSON to XML

Steps

  1. Create a project utils_xml.
  2. Create a JavaScript service with the name json2xml.js.
  3. Enter the following content:
1
2
3
4
5
6
7
8
9
10
11
12
13
var xml = require('utils/v3/xml');
var response = require('http/v3/response');

var input = '{"a":{"b":"text_b","c":"text_c","d":{"e":"text_e"}}}';
var result = xml.fromJson(input);

console.log(('XML: ' + result));
response.println(JSON.stringify('XML: ' + result));

response.flush();
response.close();


For more information, see the API documentation.

Edit