开发者

how to pass a variable to an XPathExpression

开发者 https://www.devze.com 2023-03-10 16:27 出处:网络
i want to pass the value of a variable in XPathExpression. I want to put the id value in a variable. How开发者_开发百科 can I do that? Below is the code;

i want to pass the value of a variable in XPathExpression. I want to put the id value in a variable. How开发者_开发百科 can I do that? Below is the code;

XPathExpression expr = xpath.compile("//Number[@id=1]/Movies/text()");

Above, I want to put the value of id in a variable. I tried int num =1 but doesn't works. Thanks.


String yourArg= "1";
XPathExpression expr = xpath.compile("//Number[@id="+yourArg+"]/Movies/text()");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号