java


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>1.0.1.0</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.

Related Links

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

Categories

HOME
xamarin
arduino-uno
vbscript
webpack
push-notification
google-api-php-client
plot
appx
cplex
rsync
analysis
malloc
sqlite3
ip
win32gui
windows-server
webrequest
imacros
hapi
quartz-scheduler
vaadin7
evopdf
beyondcompare
nhibernate-envers
firefox-webextensions
alpine
textfield
introduction
autoconf
graphicsmagick
bootstrap-tour
java-7
p-value
one-to-many
facet
uninstall
phpfox
web-api-testing
spring-mybatis
strncpy
buck
log4js-node
primitive
bluestacks
phonegap
.net-4.0
mapbox-gl
adobe-premiere
serve
dynamics-crm-2013
cookiecutter-django
tasker
ruby-on-rails-3.1
reportingservices-2005
auto-update
pango
paxos
dandelion
celery-task
jlink
statsd
kbuild
composite-key
akka-cluster
sqldf
blacklist
or-tools
specrun
word-vba-mac
medium.com
qdialog
computer-algebra-systems
security-testing
ionic
interrupted-exception
cisco-ios
javax.mail
gwidgets
zend-route
project-planning
jquery-layout
expected-exception
dealloc
fmod
mcts
flexmojos
mysqltuner
dexterity
flash-builder4.5
factory-method
angularjs-controller
bitsharp
viewswitcher
dbproviderfactories
bubble-chart
punbb
cinema-4d
mongomapper
mysql-error-1005
cxxtest
revisions
dbal
firefox-5
web-architecture
libs
text-coloring

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App