Search code examples
xmljsonjaxbmarshallingxstream

Conversion of Java object into XML and parse it using DOM/SAX


I need to convert Java object into XML object and send it across to client browser from server.

And in client browser, i need to parse the obtained XML object using DOM/SAX or anything that suits and display it in UI.

Which one suits the above? Could any of them help me out in this?


Solution

  • You can use the JAXB API for your problem. JAXB(Java Architecture for XML Binding) uses annotations to convert Java object to / from XML Content. JAXB solves the following puposes:

    Marshalling – Convert a Java object into a XML Content.

    Unmarshalling – Convert XML content into a Java Object.

    You can find the simple example of JAXB at here.