Possible Duplicate:
Create XML file using java
In Java to create the JSONObject {"box":"tissue","desk":"wood"} all I need to do is
JSONObject json = new JSONObject();
json.put("box","tissue");
json.put("desk","wood");
And to create the JSONObject {"my-stuff":{"box":"tissue","desk":"wood"}} all I need to do is
JSONObject json = new JSONObject();
json.put("box","tissue");
json.put("desk","wood");
JSONObject myStuff = new JSONObject();
myStuff.put("my-stuff",json);
Then to get the String representations back, I just do json.toString() or myStuff.toString().
I happen to be using org.codehaus.jettison.json.JSONObject; but really that's how JSONObject works.
Is there an equivalently simple way to create XML in Java? If not, still, what's the simplest way to do what I just did -- in XML?