You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Prashanth.S" <su...@yahoo.com> on 2004/01/22 04:11:56 UTC

[OT]Variable evaluation in XAPTH 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!

Re: [OT]Variable evaluation in XAPTH expression

Posted by "Prashanth.S" <su...@yahoo.com>.
Hi kris,
Thanks a lot...This code works for me...
Thanks once again for solving all my problem.
Prashanth
 


Kris Schneider <kr...@dotech.com> wrote:
The JDOM XPath class has a method called setVariable, and variables in 
XPath expressions start with the $ character. I've never played with the 
JDOM XPath stuff, but I assume it's something like:

XPath xp = XPath.newInstance("/*/*/subcategory[@mappedname=$map]");
xp.setVariable("map", "europe");

Prashanth.S wrote:

> 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

-- 
Kris Schneider 
D.O.Tech 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

Re: [OT]Variable evaluation in XAPTH expression

Posted by Kris Schneider <kr...@dotech.com>.
The JDOM XPath class has a method called setVariable, and variables in 
XPath expressions start with the $ character. I've never played with the 
JDOM XPath stuff, but I assume it's something like:

XPath xp = XPath.newInstance("/*/*/subcategory[@mappedname=$map]");
xp.setVariable("map", "europe");

Prashanth.S wrote:

> 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

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org