This content has been marked as final. Show 2 replies
Note: there is no best, it makes no sense to ask for it.
jmart wrote:JAXB should be able to do the XML to object hierarchy translation. Its a pretty standard API for which you should be able to find mountains of examples. All you have to basically do is create the proper object hierarchy and put some minimal annotations on it.
Is there a better way to deal with this? Is there like a tool or library that will take the XML ias input and put it into a generalized container with maps and such that I can yank out the data I want?
In the past every time I've had to process XML's I've had an XSD that I could use for marshalling the XML into a bean. But now I have to communicate to an API that returns XML's that do not have any XSD or other type of XML description document.
I was just going to use dumb string parsing and matching. Is there a better way to deal with this? Is there like a tool or library that will take the XML ias input and put it into a generalized container with maps and such that I can yank out the data I want?
So what is stopping you from creating your own XSD?
You have to know the basic structure to parse and deal with the data anyway. So why not just capture the structure you need into an XSD and then use that XSD the same way you always have (e.g. XMLBeans or other).
If you search the net you can find some freeware libraries that can create a basic XSD from an XML doc. The more complete the XML sample is the better job they can do. Use one of those to get the first draft of an XSD and then spruce it up.
You could also use Apache Commons Digester to just access the raw XML.