The moose likes XML and Related Technologies and the fly likes how to generalise this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to generalise this code" Watch "how to generalise this code" New topic

how to generalise this code

harishak reddy

Joined: Jun 14, 2012
Posts: 1
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 can i generalise this code? I am new to java.Can any one give a solution
Thank you !
I agree. Here's the link:
subject: how to generalise this code
It's not a secret anymore!