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
  • 1
    So you used XStream, but where exactly? Show some code pal. This is not a code factory, IMO. Commented Oct 8, 2010 at 6:50

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.