Suppose there is a XML in my J2ME application :
For you XML sample you could write a class like:
class Client {
String id;
String name;
String email;
}
And unmarshall your XML to it. I have shared a way of doing this with SAX from JSR 172 at http://smallandadaptive.blogspot.com.br/2010/11/xml-data-binding.html.
To marshall your class back to XML you can create a method like:
String toXML() {
StringBuffer sb = new StringBuffer();
sb.append("<client id=\"").append(id).append("\">");
sb.append("<name>").append(name).append("</name>");
sb.append("<email>").append(email).append("</email>");
sb.append("</client>");
return sb.toString();
}