Android examples for XML:JAXB
Write Java Object to XML using Java Bean XML Encoder
//package com.java2s; import java.beans.XMLEncoder; import java.io.*; public class Main { public static void main(String[] argv) throws Exception { String filename = "java2s.com"; Object obj = "java2s.com"; Write(filename, obj);//from w w w. j a va 2 s . c om } public static void Write(String filename, Object obj) throws FileNotFoundException { XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream( new FileOutputStream(filename))); encoder.writeObject(obj); encoder.close(); } }