title: How could I get the result for "For" operation?
body: <p>What I wanted to do is get the resut which is generated from the following class:</p>
  
  <pre><code>public class QueryXML {
  
  public String query;
  public QueryXML(String query){
      this.query=query;   
  }
  
  public void query() throws ParserConfigurationException, SAXException,IOException,XPathExpressionException {
  
  
    // Standard of reading an XML file
  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  factory.setNamespaceAware(true);
  DocumentBuilder builder;
  Document doc = null;
  XPathExpression expr = null;
  
  builder = factory.newDocumentBuilder();
  doc = builder.parse("C:data.xml");
  
  // create an XPathFactory
  XPathFactory xFactory = XPathFactory.newInstance();
  
  // create an XPath object
  XPath xpath = xFactory.newXPath();
  
  // Compile the XPath expression
  expr = xpath.compile(query);
  // Run the query and get a nodeset
  Object result = expr.evaluate(doc, XPathConstants.NODESET);
  
  // Cast the result to a DOM NodeList
  NodeList nodes = (NodeList) result; 
  for (int i=0; i&lt;nodes.getLength();i++){
   System.out.print(nodes.item(i).getNodeValue());
    }
   }
  }
  </code></pre>
  
  <p>This class is called from this other one:</p>
  
  <pre><code>public class FindUser {
  
  public static void main(String[] args) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException {
  
          String Queries[]={"//Employees/Employee/Firstname/City/@value", "//Employees/Employee/Firstname/Lastname/@value"};
  
          for (int x =0; x &lt; Queries.length; x++){
              String query = Queries[x];
          QueryXML process = new QueryXML(query);
          process.query();
  
        }
    }
  }
  </code></pre>
  
  <p>Those class are working fine and I can see the result in console, but I would like to assign the rsult of "process.query()" to one variable in order to work with it after this proccess.</p>
  
  <p>I dont know if it's possible or even if it's a good idea to assign the "for" operation to a variable and give it back as a return(something). </p>
  
  <p>Many thanks</p>
  
  <p>Cheers!!</p>
  
  <p>Javi</p>