Java XML JAXB Object to XML getXMLString(Object person, Class clazz)

Here you can find the source of getXMLString(Object person, Class clazz)

Description

get XML String

License

Open Source License

Declaration

public static String getXMLString(Object person, Class<?> clazz) 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;

public class Main {
    public static String getXMLString(Object person, Class<?> clazz) throws JAXBException {
        StringWriter sw = new StringWriter();
        JAXBContext context = JAXBContext.newInstance(clazz);
        context.createMarshaller().marshal(person, sw);
        String output = sw.toString();
        System.out.println(output);
        return output;
    }//from   w  ww .  ja v  a 2s  .c o  m
}

Related

  1. convertToXml(Object obj, String encoding)
  2. createXML(Object o)
  3. getObjects(List> objEls)
  4. getObjects(List objEls)
  5. getXmlString(JAXBElement versioningInfo, Boolean formatXml, Schema schema)
  6. getXmlString(T jaxbObject)
  7. Object2Xml(Object object)
  8. objectToXML(Class cls, Object entity)
  9. ObjectToXml(Object object)