title: Reading attributes from XML elements
body: <p>I'm trying to display the values of "x" using the Java code posted below, but it displays nothing. Please let me know where my mistake is:</p>
  
  <p>Java code:</p>
  
  <pre><code>for (int temp = 0; temp &lt; nList.getLength(); temp++) {
    Node nNode = nList.item(temp);
    System.out.println("\nCurrent Element :" + nNode.getNodeName());
    System.out.println("\n"+nList.getLength());
    if (nNode.getNodeType() == Node.ELEMENT_NODE) {
      Element eElement = (Element) nNode;
      if(eElement.getAttribute("place") != null){
        System.out.println("x: " + eElement.getElementsByTagName("place").item(0).getTextContent());    
      }
    }
  }
  </code></pre>
  
  <p>XML file:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;document&gt;  
  &lt;group id="Fontanestra"&gt;
  &lt;place  x="4222873.962227057"   y="2902240.7064015563"  class="hdlamp lamp651   
  Fontanestra"/&gt;
  &lt;place  x="4222675.856667058"   y="2902341.1436763224"  class="hdlamp lamp745 
  Fontanestra"/&gt;
  &lt;place  x="4222761.571650493"   y="2902285.145924819"   class="hdlamp lamp871 
  Fontanestra"/&gt;
  &lt;place  x="4222703.30618614"    y="2902320.7303823503"  class="hdlamp lamp972 
  Fontanestra"/&gt;
  &lt;place  x="4222802.65477977"    y="2902265.5807657656"  class="hdlamp lamp1084 
  Fontanestra"/&gt;
  &lt;place  x="4222935.246730494"   y="2902220.7360558496"  class="hdlamp lamp1110  
  Fontanestra"/&gt;
  &lt;place  x="4222734.639113373"   y="2902300.2547685634"  class="hdlamp lamp1215 
  Fontanestra"/&gt;
  &lt;place  x="4222837.368032"      y="2902252.747460649"   class="hdlamp  
  lamp1225 Fontanestra"/&gt;
  &lt;place  x="4222904.859771981"   y="2902230.8135758354"  class="hdlamp lamp1336  
  Fontanestra"/&gt;
  
  &lt;/group&gt;        
  &lt;/document&gt;
  </code></pre>