/** 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 com.ricebridge.xmlman.XmlSpec; import java.util.List; /** This is a very simple example that shows you how to load and * save XML data using XML Manager. The data to load is taken from * the file "products.xml", in the same folder as this Java source * file. The saved data is written to a new file called "table.htm", * also in the same 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 HtmlTable { public static void main( String[] args ) { // 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 what data to extract from the XML file RecordSpec inputrs = new RecordSpec( "/shop/product", new String[] {"@code","name","price"} ); // And now load the data. List data = xmlman.load( "products.xml", inputrs ); // The data we just loaded is available as a List of String[] arrays. // We can loop through it manually to access it, but we can also // use XML Manager to output the data in a different format. // Get the XmlSpec object to change the output settings XmlSpec xmlspec = xmlman.getXmlSpec(); xmlspec.setHeader("
| Code | Name | Price |
|---|---|---|