import java.io.File;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
public class XPathTest {
private static void debug(Object object){
System.out.print(" DEBUG ");
System.out.println(object);
}
private static void error(Object object){
System.out.print(" ERROR ");
System.out.println(object);
}
public static void main(String[] args){
new XPathTest();
}
public XPathTest(){
try{
Document document=getXmlByPath("c:\\temp.xml");
setParameterForGet(document);
}catch(Exception ex){
}
}
private void setParameterForGet(Document document){
try{
XPathFactory xpathFactory=XPathFactory.newInstance();
XPath xpath=xpathFactory.newXPath();
XPathExpression expression=xpath.compile("//response/results/*");
NodeList nodeSet=(NodeList)expression.evaluate(document, XPathConstants.NODESET);
debug("//response/results/ length:"+nodeSet.getLength());
if(nodeSet.getLength()>0){
/* this.parametersForGet.clear();
for(int counter=0;counter