Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to generalise this code

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

//first

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++) {
System.out.println(nodes.item(i).getNodeValue());

}
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 !
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic