This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to generalise this code" Watch "how to generalise this code" New topic
Author

how to generalise this code

harishak reddy
Greenhorn

Joined: Jun 14, 2012
Posts: 1
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
 
subject: how to generalise this code
 
Similar Threads
XPath Question
Can't pin down this NullPointerException :(
XPath
Cant run sample Xpath example
Retrieve values for a complicate XML file (Java)