I am trying to parse my giant xml using SAX as well as DOM parser. DOM parser is taking lots of memory and implementation of SAX parseh is making me check some nested tags with their names,taking lots of time and does not look efficient.
I parsed xml using JAXB and made java objects of it and I am getting values from getters .(The classes are generated using XSD of my xml file)
JAXBContext jaxbContext = JAXBContext.newInstance(Myclass.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
InputStream in = new ByteArrayInputStream(xmldata.getBytes()); Myclass classobject = (Myclass) jaxbUnmarshaller.unmarshal(in);
The classobject is giving what I want.
My project is not webservice project.So my question is : Is it recommended using JAXB for Java Projects?I am technically nor parsing xml(JAXB comes with DOM and SAX) ,so it unmarshlling is parsing?