FileDocCategorySizeDatePackage
TestModelBuilder.javaAPI DocExample731Sat Apr 23 22:35:34 BST 2005None

TestModelBuilder

public class TestModelBuilder extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		SAXParserFactory factory = SAXParserFactory.newInstance();
		SAXParser saxParser = factory.newSAXParser();
		XMLReader parser = saxParser.getXMLReader();
		SAXModelBuilder mb = new SAXModelBuilder();
		parser.setContentHandler( mb );

		parser.parse( new InputSource("zooinventory.xml") );
		Inventory inventory = (Inventory)mb.getModel();
		System.out.println("Animals = "+inventory.getAnimals());
		Animal cocoa = (Animal)(inventory.getAnimals().get(1));
		FoodRecipe recipe = cocoa.getFoodRecipe();
		System.out.println( "Recipe = "+recipe );