Java Utililty Methods XML JAXB String to Object

List of utility methods to do XML JAXB String to Object

Description

The list of methods to do XML JAXB String to Object are organized into topic(s).

Method

TXmlToObject(String xml, Class type)
Transforms a XML string to an Object using javax.xml.bind.Unmarshaller.
JAXBContext jaxbContext = JAXBContext.newInstance(type);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
T obj = (T) jaxbUnmarshaller.unmarshal(new StringReader(xml));
return obj;
voidxmlToXhtml(T catalog, StreamSource xslt, StreamResult result)
xml To Xhtml
try {
    TransformerFactory.newInstance().newTransformer(xslt)
            .transform(new JAXBSource(JAXBContext.newInstance(catalog.getClass()), catalog), result);
} catch (JAXBException | TransformerException e) {
    throw new IllegalStateException(e);