title: How to traverse the nodes and get their attribute names? I'm using DOMParser
body: <p>The xml file looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;parent&gt;
      &lt;child ID="1" Name="CHILD" Order="1"&gt;
          &lt;child ID="1" Name="SUB_CHILD" Order="1"&gt;
          &lt;/child&gt;
      &lt;/child&gt;
      &lt;child ID="2" Name="CHILD2" Order="1"&gt;
          &lt;child ID="1" Name="SUB_CHILD" Order="1"&gt;
          &lt;/child&gt;
      &lt;/child&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>CODE (NEW):</p>
  
  <pre><code> void listNodes(NodeList list) {
      if (list.getLength() &gt; 0) {
          for (int i = 0; i &lt; list.getLength(); i++) {
              System.out.println("-------------------");
              if (list.item(i).hasAttributes()) {
                  NamedNodeMap attrs = list.item(i).getAttributes();
                  for (int index = 0; index &lt; attrs.getLength(); index++) {
                      Attr attribute = (Attr) attrs.item(index);
                      if(attribute.getName().equals("Name")){
                       names[index] = ????                            
                          }
                  }
              }else{
                  System.out.println(list.item(i).getNodeName()+ " has no attributes");
              }
              System.out.println("-------------------");
          }
      }
  }
  </code></pre>
  
  <p>I have edited the code. Now I know <code>attribute</code> has the attributes. How do I extract the attribute <code>Name</code> and put it inside a string array.</p>