Posts

Showing posts with the label XMLBeans

XMLBeans - Spare me the parsing and mapping !

I have been using Castor(http://www.castor.org) for a while to translate XML to JavaBeans vice versa. It was ok and reliable but our XML got complicated, it was tedious and cumbersome to maintain the XML Mapping file. Our mapping file keeps growing bigger as our objects gets more complicated. On top of that we have to maintain our XML schemas as well. So we have to maintain the XML mapping file and the XML schema. Then i stumbled upon XMLBeans. XMLBeans got me hooked just by not having to maintain a mapping file. Here are the few easy steps that i followed when i used XMLBeans. 1.) Download and Install XMLBeans (http://xmlbeans.apache.org/). I got version 2.1.0 2.) Create the XML Schema 3.) Do a SCOMP (Please refer to XMLBeans documentation) 4.) Once the XMLBeans jar for my XML Schema was created then it was ready to use. Here is a sample Code: Sample Code processing an XML Message to an Object xmlTest is the XML Message in String InstructorQualification is the root element of the XML