Thanks. So, I try:
String expr = "/StateTable/State[Name='Tender']/Action[InputEvent=$m]/ProcessFile"; String para = "Cash"; XPath xp = doc.createXPath(expr); SimpleVariableContext vc = new SimpleVariableContext(); vc.setVariableValue("m",(Object) para); xp.setVariableContext(vc); System.out.println(doc.valueOf(xp.getText())); What this does is: org.dom4j.XPathException: Exception occurred evaluting XPath: /StateTable/State[Name='Tender']/Action[InputEvent=$m]/ProcessFile. Exception: Variable :m Cheers Tony > I'd appreciate a pointer to an example of how to set up a variable > context correctly. My search on the net has only turned up other requests > for the same, but no answers! > > What I'm trying is: > > String expr = "/StateTable/State[Name='Tender']/Action[InputEvent=$m]/ProcessFile"; > String para = "Cash"; > XPath xp = doc.createXPath(expr); > SimpleVariableContext vc = new SimpleVariableContext(); > vc.setVariableValue("$m",(Object) para); > xp.setVariableContext(vc); > System.out.println(doc.valueOf(xp.getText())); > > which doesn't work, although this is fine: > > String expr = "/StateTable/State[Name='Tender']/Action[InputEvent='Cash']/ProcessFile"; > XPath xp = doc.createXPath(expr); > System.out.println(doc.valueOf(xp.getText())); Try setting the variable "m" instead of "$m". The dollar-sign isn't part of the variable name. -bob _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest