Unmarshalling XML Elements to Java Classes

See Also 

The Java Architecture for XML Binding API (JAXB) provides a client application the ability to convert XML data into a tree of Java classes. The IDE provides a code template that you can use to generate a code snippet as the basis for this task.

To unmarshall XML elements to Java classes:

  1. Type jaxbu in the Source Editor for Java files and then press Tab. The snippet is created, as follows:
    try {
        javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(Object.class.getClass().getPackage().getName());
        javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
        Object.class =  unmarshaller.unmarshal(new java.io.File("File path")); //NOI18N
    } catch (javax.xml.bind.JAXBException ex) {
        // XXXTODO Handle exception
        java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex); //NOI18N
    }
  2. Now incorporate it in the rest of your code.
See Also
About Mapping XML to Java
Generating Java Classes from XML Schema Documents

Legal Notices