how to pass a variable to an XPathExpression
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()");
精彩评论