I want to convert JSON array into XML, but during conversion it generates invalid XML file:
String str = "{ 'test' : [ {'a' : 'A'},{'b' : 'B'}]}";
JSONObject json = new JSONObject(str);
String xml = XML.toString(json);
I used above code as suggested in Converting JSON to XML in Java
But if I tried to convert JSON object into XML it give invalid XML (error: The markup in the document following the root element must be well-formed.
) which is
<test><a>A</a></test><test><b>B</b></test>
Can anybody please tell me how to get valid XML from JSON array or how to wrap JSON array while converting into XML?
Thanks in advance.