Parse XML TO JAVA POJO in efficient way

DroidEngineer picture DroidEngineer · Feb 9, 2013 · Viewed 51.7k times · Source

How to parse and create java pojo for below xml in an efficient way? Kindly suggest any efficient parser.

XML format is

<?xml version="1.0" encoding="utf-8"?>
<CCMainRootTag ID="12">
  <Header TableName="TableName"    TableVersion="12" TableID="12" CreatedDate="2013-02-09T15:35:33" CreatedByUserName="ABC" CreatedBySystem="ABC" />
  <ClassPrimary ID="12" Code="Y" DescriptionDK="DK language " DescriptionUK="" DefDK="" DefUK="" IFDGUID="">
    <ObjectClass ID="12" Code="YA" DescriptionDK="DK Language" DescriptionUK="" DefDK=""     DefUK="" IFDGUID="">
      <Synonym>
        <Concept Description="Description" Language="DK" />
        <Concept Description="" Language="UK" />
        <Concept Description="Description" Language="DK" />
        <Concept Description="" Language="UK" />
        <Concept Description="Description" Language="DK" />
        <Concept Description="" Language="UK" />
        <Concept Description="Description" Language="DK" />
        <Concept Description="" Language="UK" />
      </Synonym>
    </ObjectClass>
    <ObjectClass ID="12" Code="YB" DescriptionDK="DK Language" DescriptionUK="" DefDK="" DefUK="" IFDGUID=""> </ObjectClass>
    <ObjectClass ID="12" Code="YC" DescriptionDK="DK Language" DescriptionUK="" DefDK="" DefUK="" IFDGUID=""> </ObjectClass>
    <ObjectClass ID="12" Code="YD" DescriptionDK="DK language" DescriptionUK="" DefDK="" DefUK="" IFDGUID=""> </ObjectClass>
  </ClassPrimary>
</CCMainRootTag>

I already use thisLink but it have slow performance and having problem did't valid pojo.

I want to parser which provide me direct java pojo in a efficient way.

Answer

CuriousMind picture CuriousMind · Feb 9, 2013

You can use JAXB to convert XML into Java POJOs. But before you finalize the solution check this site for performance comparison.