• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to generalise this code  RSS feed

harishak reddy
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();


XPathExpression expr
= xpath.compile("//Pool[@name='BLR' and @enabled='true']/*/text()");

Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;

System.out.println("pool name BLR and enabled True");

for (int i = 0; i < nodes.getLength(); i++) {

I have many XPathExpression like expr1 ,expr2 etc to read and display.how can i generalise this code? I am new to java.Can any one give a solution
Thank you !
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!