[jdom-interest] variable evaluation in XPATH expression

Alastair Rodgers alastair.rodgers at phocis.com
Thu Jan 22 02:25:44 PST 2004


Oops! Formatting got a bit screwed up there. Here it is again:

XPath xpath = new JDOMXPath("/*/*/subcategory[@mappedname=$map]");
SimpleVariableContext vars = new SimpleVariableContext(); 
vars.setVariableValue(null, "map", "europe"); 
xpath.setVariableContext(vars); 
Element result = (Element)xpath.selectSingleNode(doc);



> -----Original Message-----
> From: Alastair Rodgers 
> Sent: 22 January 2004 10:23
> To: 'Prashanth.S'; jdom-interest at jdom.org
> Subject: RE: [jdom-interest] variable evaluation in XPATH expression
> 
> 
> Something like the following should do it:
> 
> XPath xpath = new JDOMXPath("/*/*/subcategory[@mappedname=$map]");
> SimpleVariableContext vars = new SimpleVariableContext(); 
> vars.setVariableValue(null, "map", "europe"); 
> xpath.setVariableContext(vars); Element result = 
> (Element)xpath.selectSingleNode(doc);
> 
> 
> Al.
> 
> 
> -----Original Message-----
> From: jdom-interest-admin at jdom.org 
> [mailto:jdom-interest-admin at jdom.org] On > Behalf Of 
> Prashanth.S
> Sent: 22 January 2004 03:11
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] variable evaluation in XPATH expression
> 
> 
> Hi all,
> Iam using jdom for xml parsing....so to search a particular 
> element in a xml iam using XPATH and iam trying to construct 
> XPATH expression dynamically....is it possible to use 
> variables inside XPATH expression....like String 
> map="europe"; XPath servletPath = 
> XPath.newInstance("/*/*/subcategory[@mappedname=map]");
> 
> Iam eagerly waiting for reply...
> Thanks
> Prashanth
> 
> 
> 
> 
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> 



More information about the jdom-interest mailing list