Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import javax.xml.bind.JAXBContext;

import javax.xml.bind.Unmarshaller;
import java.io.StringReader;

public class Main {
    public static Object xmlStringToObject(String xmlString, Class clazz) throws Exception {
        JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        StringReader reader = new StringReader(xmlString);
        return unmarshaller.unmarshal(reader);
    }
}