Java XML JAXB Unmarshaller unmarshall(Class c, Object o)

Here you can find the source of unmarshall(Class c, Object o)

Description

unmarshall

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    public static <T> String unmarshall(Class<T> c, Object o) throws JAXBException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.StringWriter;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> String unmarshall(Class<T> c, Object o) throws JAXBException {
        JAXBContext ctx = JAXBContext.newInstance(c);
        Marshaller marshaller = ctx.createMarshaller();
        StringWriter entityXml = new StringWriter();
        marshaller.marshal(o, entityXml);

        return entityXml.toString();
    }/*from   ww  w.  j  a va 2s .  com*/
}

Related

  1. unmarshalFromString(Class clz, String input)
  2. unmarshalFromXml(Class clazz, String xml)
  3. unmarshalFromXml(final String xml, Class destinationClass)
  4. unmarshalInstance(final String data, final Class expectedType)
  5. unmarshall(Class clazz, String string)
  6. unmarshall(Class cls, Element domRequest)
  7. unmarshall(InputStream is, Class clz)
  8. unmarshall(InputStream toUnmarshall, Class clazz)
  9. unmarshall(JAXBContext c, Element e)