POLITECHNIKA RZESZOWSKA - Wydział
import j avax.xml.bind.JAXBContext; import javax.xml.bind-Unmarshaller;
JAXBContext jc = JAXBContext.newlnstance("jp.jaxb") ; Utworzenie obiektu unmarshaller
Unmarshaller unmarshaller = jc.createUnmarshaller() ; Wywołanie metody unmarshal
Products products = (Products)unmarshaller.unmarshal(new
File ("products.xml")); Zastosowanie metod typu get klas dostępu do danych XML otrzymanych ze schematu XML Schema - przetwarzanie obiektów
List productList = products.getProduct();
Product product =(Product)productList.get(0) ;
String name = product.getName();
JAVA Wykład 13
Copyright© 2012 Jan PROKOP
40/236