Hello, I'm sorry to ask such a basic question but I have a use case where I receive a collection and want to access an element of that collection. I've tried several methods to get to an elements, iindexing and calling methods but to no avail. The curretn thing I'm trying is this :
public void testJXContext(){ List<String> objTest = new ArrayList<String>(); objTest.add("test1"); objTest.add("test2"); JXPathContext objContext = JXPathContext.newContext(objTest); System.out.println(objContext.getValue("[1]")); } However that give eme stack trace of : org.apache.commons.jxpath.JXPathException: Invalid XPath: '[1]'. Syntax error at the beginning of the expression at org.apache.commons.jxpath.ri.Parser.parseExpression(Parser.java:60) at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.compileExpression( JXPathContextReferenceImpl.java:218) at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue( JXPathContextReferenceImpl.java:247) at com.ziath.eventregistration.email.test.EMailFormatterTest.testJXContext( EMailFormatterTest.java:18) <snip> This is being run through JUnit executing via eclipse. Could someone be so kind as to let me know what the syntaz should be here to get it to work? Thanks, in advance for your help. Cheers, Neil