how to convert string in the form of xml to xml format in java
I have xml data in the form of string. I would like to know how to convert it using Java. In MULE ESB I have the string message in logger showing it as: [payload:java.lang.String] I need to store each elements and give a response in XML. How do I configure it with JAXB or any other process? <EAI_MESSAGE> <EAI_HEADER> <MsgFormat>ISO8583</MsgFormat> <MsgVersion>184.108.40.206</MsgVersion> </EAI_HEADER> <EAI_BODY> <FundTransferRequest> <CustomerId>CT1010</CustomerId> <SourceAccNo>12346789012345</SourceAccNo> <SourceAccName>SOURAV MUKHERJEE</SourceAccName> <SourceAccType>SAVINGS</SourceAccType> <SourceIFSC>SBI1010</SourceIFSC> <Amount>5000.00</Amount> </FundTransferRequest>`enter code here` </EAI_BODY>
Your are looking in the correct direction when you mention JAXB. JDK comes with xjc which allows you to auto-generate classes that are needed to unmarshall and marshall XML files. You can follow the following steps to build a solutions Build XML Schema for input and output XML format. There are number of tools available to achieve this. (How to generate JAXB classes from just XML) Use the XML schemas to generate JAXB java library. (Generate your JAXB classes in a second with xjc) Now configure you java application to unmarshall (build java objects from XML) using input JAXB library. (Using JAXB to Generate Java Objects from XML Document) Build Java object structure using classes generated using XJC for needed for output XML format using the Java objects created by unmarshalling. This is pure Java programming task Now, generate the output XML needed using marshaller in JAXB library This seems complex but except for generating output Java data structure from input Java, rest of the process is straight forward. Hope this helps.
How do I move a multidimensional array into another method?
Unable to turn off logging in console in logback
How to use navigateToRow() and findRow() of HtmlDataTable in icefaces 1.8
Differents between SDA and DDA in JavaCard?
Simple mapping configuration List<Object> field
Declare Generic Type for class based on method parameter
ClassCastException: ArrayList cannot be cast to
Spring Roo 1.3.2 And Java 8
validate statement using regular expression
Debug a java program by executing “gradle run”
How to add string in the last foreach item?
JavaFx: NullPointerException when setting text to label from two different functions
Calling a method from overflowMenu?
Adding word objects in to an ArrayList
Unable to see abstract base class methods via child class instance using Reflection [duplicate]
How to truncate String contain emoji by byte size