FileDocCategorySizeDatePackage
TestJAXBMarshall.javaAPI DocExample822Sat Apr 23 22:35:42 BST 2005None

TestJAXBMarshall

public class TestJAXBMarshall extends Object

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

		ObjectFactory factory = new ObjectFactory();

		Inventory inventory = factory.createInventory();
		Animal fang = factory.createAnimal();
		fang.setName("Song Fang");
		fang.setSpecies("Giant Panda");
		fang.setHabitat("China");
		fang.setFood("Bamboo");
		fang.setTemperament("Friendly");
		fang.setWeight(45.0);
		inventory.getAnimal().add( fang );

		JAXBContext jbcontext = JAXBContext.newInstance("learningjava");
		Marshaller marshaller = jbcontext.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		marshaller.marshal( inventory, System.out );