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 );