Dump a Java HashMap<K,V> to XML and back
does anyone know of a good library or开发者_C百科 method of converting the contents of a HashMap to XML and then parsing this to reconstruct the HashMap?
The XStream library is what you want. http://x-stream.github.io/
It has a HashMap converter, and a tutorial on how to use convertors.
Java Architecture for XML Binding (JAXB) allows Java you to map Java classes to XML representations. JAXB provides two main features: the ability to marshal Java objects into XML and tunmarshal XML back into Java object
Where to start? Pick a tutorial from these:
http://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding
http://jaxb.java.net/
http://java.sun.com/developer/technicalArticles/WebServices/jaxb/
In 15 minutes your done!
精彩评论