I had a similar situation before, but my XML parser needed some configuration. My approach was: a) parsing, b) configuration.
The configuration part builds around XPath expressions that are passed through properties. This is a static XPath expression and needs to be updated if the input XML message changes.
Part of the parsing engine executes these expressions to query the xml element, attribute, etc. to populate a java object.
EDIT:
For example, given xml (simplified, without namespace):
<msg> <something> <somenode> <version>1.0.0</version> </somenode> </something> </msg>
Code example: (simplified)
String myXpExpr = "//version/text()";
This will give you "1.0.0" as resultObject.
source share