tags:

views:

28

answers:

1

I have two java classes....

public class Item {
    private int itemIndex;
    private String containerType;
    private Map<String, List<String>> contentType;
    private String status;
    private List<String> remark; 
    // their getters and setters
}

Please tell me how to convert Item object to xml and xml to Item object? I have used XStream jar for conversion. I need to store multiple Item (list of items) in xml. Please provide full coding in JAVA to add a new item with existing items (stored in xml).

+1  A: 

Sample code

ObjectOutputStream out = xstream.createObjectOutputStream(someWriter);

out.writeObject(new Person("Joe", "Walnes"));
out.writeObject(new Person("Someone", "Else"));
out.writeObject("hello");
out.writeInt(12345);

out.close();
org.life.java