/** You may copy this example and use it for any purpose, commercial or otherwise. */ import com.ricebridge.xmlman.XmlManager; import com.ricebridge.xmlman.RecordSpec; import java.util.List; import java.util.ArrayList; /** This is a very simple example that shows you how to save data * using XML Manager. The data to save is hard-coded as a list * of String[] arrays. The output file is called "more-presidents.xml", and * will be saved in the current folder. * * To compile and run this program, you will need to include xmlman.jar * (in the lib folder of the XML Manager distribution) in your CLASSPATH. */ public class Save { public static void main( String[] args ) { // here is our data - hard-coded for the sake of this example ArrayList data = new ArrayList(); data.add( new String[] { "Richard Nixon", "tricky@whitehouse.gov" } ); data.add( new String[] { "Harry S. Truman", "haberdasher@whitehouse.gov" } ); data.add( new String[] { "Thomas Jefferson", "sage@whitehouse.gov" } ); // To use XML Manager, start by creating a new XmlManager object. XmlManager xmlman = new XmlManager(); // Then you need a RecordSpec object. // This tells XML Manager how to format the XML file for output RecordSpec rs = new RecordSpec( "/list/president", new String[] {"name","email"} ); // And now save the data to the file more-presidents.xml xmlman.save( "more-presidents.xml", rs, data ); } }