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.
Can't put Double number in BigDecimal variable
Java safest way to check client jar server side
Deploy WAR on Tomcat
UnsupportedClassVersionError while using Jmockit in a Java 1.5 Project
adding item to jlist from jlist
Constructor with many required parameters
Unity 2d instantiating on mouse location trouble, Please advise
String replace according to position?
Android - get name and quantity of each product in same line
Truevault request failing using entity builder on android while the curl equivalent is successful. Any suggestions for changes in the code?
Java Server - How to take input from InputStreamReader and convert to a String?
Which iterator should I use to create instances from feature value pairs (Mallet api)?
Crash on startup: “requestFeature() must be called before adding content” [duplicate]
Loop through an array of strings, and remove the vowel 'a' (java) [duplicate]
File.separator vs. File.pathSeparator [duplicate]
Run su -c “command” process