title: XML get value of node on a specific attribute
body: <p>I know there are many links for this but I couldn't find a solution. Based on my searches I have come up with some code:</p>
  
  <pre><code>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  DocumentBuilder builder = factory.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  
  Document doc = builder.parse(is);
  XPathFactory xPathfactory = XPathFactory.newInstance();
  XPath xpath = xPathfactory.newXPath();
  
  XPathExpression expr = xpath.compile("//Field[@Name=\"id\"]");
  NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
  System.out.println(nl.getLength());
  for(int i=0;i&lt;nl.getLength();i++){
      Node currentItem = nl.item(i);
      String key = currentItem.getAttributes().getNamedItem("Name").getNodeValue();
      System.out.println(key);
  }
  </code></pre>
  
  <p>This is my xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;Entity Type="test-folder"&gt;
  &lt;Fields&gt;
  &lt;Field Name="item-version"/&gt;
  &lt;Field Name="id"&gt;
      &lt;Value&gt;5386&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="ver-stamp"&gt;
      &lt;Value&gt;2&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="parent-id"&gt;
      &lt;Value&gt;5310&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="system"&gt;
      &lt;Value&gt;A&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="last-modified"&gt;
      &lt;Value&gt;2014-03-03 16:35:24&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="description"&gt;
      &lt;Value/&gt;
  &lt;/Field&gt;
  &lt;Field Name="hierarchical-path"&gt;
      &lt;Value&gt;AAAAAPAADAACADC&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="view-order"&gt;
      &lt;Value&gt;0&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="name"&gt;
      &lt;Value&gt;TC77&lt;/Value&gt;
  &lt;/Field&gt;
  &lt;Field Name="attachment"&gt;
      &lt;Value/&gt;
  &lt;/Field&gt;
  &lt;/Fields&gt;
  </code></pre>
  
  <p></p>
  
  <p>I want to get the value of "Field Name='id'" which is 5386. Sorry if I am just re-posting this but I really couldn't get an answer.</p>