Java XML JAXB Unserialize readXmlFileToObj(String path, String packageName)

Here you can find the source of readXmlFileToObj(String path, String packageName)

Description

read Xml File To Obj

License

LGPL

Declaration

public static JAXBElement<?> readXmlFileToObj(String path, String packageName) throws JAXBException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import javax.xml.bind.*;

import java.io.*;

public class Main {
    public static JAXBElement<?> readXmlFileToObj(String path, String packageName) throws JAXBException {
        File file = new File(path);
        JAXBContext jContext = JAXBContext.newInstance(packageName);
        Unmarshaller unmarshaller = jContext.createUnmarshaller();
        return (JAXBElement<?>) unmarshaller.unmarshal(file);
    }//  ww  w.  j a v a2  s  .c  o m
}

Related

  1. readJAXB(Class clazz, InputStream is)
  2. readJaxbObject(InputStream inputStream, Class jaxbModelClass)
  3. readObject(Class clazz, File file)
  4. readObjectFromInputStream(final InputStream inputStream, final Class expectedType)
  5. readObjectFromXml(Class jaxbBindClass, String xmlFileName)
  6. unserialize(T component, Class returnType)