Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a Java object to an XML string, and conversely convert XML to a Java object?

Tags:

java

xml

Assume a Java object:

Object obj = new Object();

How do I store this object in the database so to persist this status, and after I store it, it should be easy to convert to a Java object like when I store it?

like image 212
tsaowe Avatar asked Feb 28 '26 04:02

tsaowe


1 Answers

Any of these will do:

  • XStream
  • XMLBeans
  • Simple

Or just plain JDK XMLEncoder / XMLDecoder (introductory article), but that's a royal pain in the donkey if you ask me.

like image 52
Sean Patrick Floyd Avatar answered Mar 01 '26 17:03

Sean Patrick Floyd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!