title: java Convert Element to string
body: <p>I am looking to get only the tag name, and not it's children. </p>
  
  <p>I have an xml like this:</p>
  
  <pre><code>  &lt;RESPONSE&gt;
      &lt;RESULT&gt;                                              !--TableName
         &lt;ADDRESS1&gt;123 Main Street&lt;/ADDRESS1&gt;               !--ColumnName
         &lt;ZIP&gt;12345&lt;/ZIP&gt;                                   !--ColumnName
      &lt;/RESULT&gt;
      &lt;RESULT&gt;                                              !--TableName
        &lt;ADDRESS1&gt;245 Elm Street&lt;/ADDRESS1&gt;                 !--ColumnName
        &lt;ZIP&gt;45678&lt;/ZIP&gt;                                    !--ColumnName
     &lt;/RESULT&gt;
     &lt;VIN&gt;                                                  !--TableName
        &lt;VIN_NUM&gt;1K45678RTW23&lt;/VIN&gt;                         !--ColumnName
     &lt;/VIN&gt;
     ….
  &lt;/REPSONSE&gt;
  </code></pre>
  
  <p>I am trying to dynamically save the xml into it's appropriate table and column names. So, I want to extract whatever the first element is, and assign it to a table name variable, and then it's children as columns. </p>
  
  <p>Here is what I am doing so far:</p>
  
  <pre><code>    private void extractToTableSet(Document doc, int appseqno ) throws Exception
  {
      NodeList responseList = doc.getElementsByTagName("RESPONSE");
      for (int i = 0; i &lt; responseList.getLength(); i++) {
          Node currentNode = responseList.item(i);
          if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
              Element tableElement = (Element) responseList.item(i);
              if (tableElement != null &amp;&amp; tableElement.hasChildNodes()) {
                  for (columnNode = tableElement.getFirstChild(); columnNode != null; columnNode = columnNode.getNextSibling()) {
                      if (columnNode.getNodeType() == Node.TEXT_NODE) {
                          columnName = columnNode.getNodeValue;
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>This way I am only able to get the values in the child nodes. Is there a way to get the name of the Element tags? Like I want to extract the value RESULT from the Document object. </p>