title: java find value of an xml attribute
body: <p>this is my xml :</p>
  
  <p>&lt;-tobject.subject tobject.subject.refnum="01016000" /></p>
  
  <p>&lt;-tobject.subject tobject.subject.refnum="10004000" /> </p>
  
  <p>I want to extract 01016000 and 10004000 from it .</p>
  
  <p>I used this code:</p>
  
  <p>NodeList nodeLst4 = doc.getElementsByTagName("tobject.subject");</p>
  
  <pre><code>        if (nodeLst4 != null) {
  
              int numberofCOdes = nodeLst4.getLength();
  
              aSubjectCodes = new String[numberofCOdes];
              for (int i = 0; i &lt; numberofCOdes; i++) {
  
               XPath xpath = XPathFactory.newInstance().newXPath();
  
               aSubjectCodes[i] = xpath.evaluate("//tobject.subject/@tobject.subject.refnum", doc);
  </code></pre>
  
  <p>the problem is that when i loop through it the evaluate method just return first number and do not give me the second value.</p>
  
  <p>and i am not sure if using  xpath.evaluate is good idea or not.</p>
  
  <p>Thanks</p>