Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication13;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import javaapplication13.Receptar.Polozka;
- import javaapplication13.Receptar.Recept;
- import javax.xml.bind.JAXBContext;
- import javax.xml.bind.JAXBException;
- import javax.xml.bind.Unmarshaller;
- /**
- *
- * @author danielplaskur
- */
- public class JavaApplication13 {
- /**
- * @param args the command line arguments
- * @throws javax.xml.bind.JAXBException
- * @throws java.io.FileNotFoundException
- */
- public static void main(String[] args) throws JAXBException, FileNotFoundException {
- JAXBContext jb = JAXBContext.newInstance(Receptar.class);
- Unmarshaller um = jb.createUnmarshaller();
- Receptar receptar = (Receptar) um.unmarshal(new FileReader("/Users/danielplaskur/NetBeansProjects/skuskaSAX/input2.xml"));
- for(Recept r : receptar.getRecepty()){
- for(Polozka p : r.getPolozky()){
- if(p.getNazov().equals("muka")){
- System.out.println(r.getNazov());
- }
- if(r.getNazov().equals("omeleta")){
- if(p.getNazov().equals("mlieko")){
- System.out.println(p.getMnozstvo() + " " + p.getJednotka());
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement