Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T toXML(Class<T> cls, String xml) {
        try {
            return (T) JAXBContext.newInstance(cls).createUnmarshaller().unmarshal(new StringReader(xml));
        } catch (JAXBException e) {
            return (T) "<>";
        }
    }
}