Question

In my project, I have used JSF and SpringDAO and webservices. I am calling various webservices which returns with XML and I need to parse and use this XML. So my question is... What can I use?

Is there anything in Spring by default that I can check? Do I need to separately parse my content and use it through core java code? or any thing else...

What can be done in this case?

Was it helpful?

Solution

The two classical XML Parser are available based on SAX and DOM. Read here for more on this.

Spring also supports Object/XML mapping. Which is,

A new feature, as of Spring 3.0, is the O/X Mapper. The concept of an O/X mapper is not new. The O stands for Object. The X stands for XML. The idea is to translate a Java object (almost always a plain old Java object or POJO) into an XML document and vice versa.

So, for example, you might have a simple bean with a few attributes and you have a business need to translate that Java object into an XML document. Spring's O/X Mapper can handle that for you. If the reverse is true (that is, you need to take an XML document and translate it into a simple Java bean), Spring's O/X Mapper can also handle that.

Read an article here or API here.

This is really interesting and can hide the complexity of XML parsing in you code. Choose it if you can.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top