commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Retter" <>
Subject Mapping Node to custom Object with JXPath
Date Mon, 07 Apr 2008 10:43:28 GMT

I have an XML document that I have read in using DOM, I am using
JXPath on the DOM Document as the context. I want to get a Node from
the DOM with JXPath and have it return it as a custom object of my
defining. In effect I am trying to map an XML Node to a custom Object.

I cant seem to get this to work, JXPath seems to always want to return
a String as the Node value. How can I acheive this please???


org.e3c.dom.Document doc = ...
JXPathContext context = JXPathContext.newInstance(doc);
ResponseExceptionList exceptionList =

My XML Document looks a bit like this -

<ErrorCode>some error code</ErrorCode>
<ErrorMessage>some error message</ErrorMessage>

My Java Class looks a bit like this -

public class ResponseExceptionList {
		public class ResponseException {
			private String errorCode = null;
			private String errorMessage = null;

			public ResponseException(String errorCode, String errorMessage) {
				this.errorCode = errorCode;
				this.errorMessage = errorMessage;

		private ArrayList<ResponseException> exceptions = new
		public ResponseExceptionList(ArrayList<ResponseException> exceptions) {
			this.exceptions = exceptions;

Adam Retter

Software Pimp Extraordinaire

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message