title: Issue with xml parsing to get child tag values in Java
body: <p>I want to parse the dynamically generated xml which do not have any predefined structure for the xml file. My Xml looks like,</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;metadata&gt;
      &lt;control for="9bd2f8fd2421eb0b0a410feaa1f482c50551486a" name="first-name" type="input" datatype="string"&gt;
                      &lt;resources lang="en"&gt;
                              &lt;label&gt;First Name&lt;/label&gt;
                              &lt;help /&gt;
                              &lt;hint&gt;Your first or given name
                              &lt;/hint&gt;
                              &lt;alert /&gt;
                      &lt;/resources&gt;
                      &lt;resources lang="fr"&gt;
                              &lt;label&gt;Pr├â┬⌐nom&lt;/label&gt;
                              &lt;help /&gt;
                              &lt;hint&gt;
                                      Votre pr├â┬⌐nom
                              &lt;/hint&gt;
                                      &lt;alert /&gt;
                      &lt;/resources&gt;
                      &lt;value&gt;Rahul&lt;/value&gt;
              &lt;/control&gt;
  
  &lt;control for="9bd2f8fd2421eb0b0a410feaa1f482c50551486b" name="last-name" type="input" datatype="string"&gt;
                      &lt;resources lang="en"&gt;
                              &lt;label&gt;Last Name&lt;/label&gt;
                              &lt;help /&gt;
                              &lt;hint&gt;Your last name
                              &lt;/hint&gt;
                              &lt;alert /&gt;
                      &lt;/resources&gt;
                      &lt;resources lang="fr"&gt;
                              &lt;label&gt;Pr├â┬⌐nom&lt;/label&gt;
                              &lt;help /&gt;
                              &lt;hint&gt;
                                      Votre pr├â┬⌐nom
                              &lt;/hint&gt;
                                      &lt;alert /&gt;
                      &lt;/resources&gt;
                      &lt;value&gt;Sharma&lt;/value&gt;
              &lt;/control&gt;
      &lt;/metadata&gt;
  </code></pre>
  
  <p>From the above xml I need to get the following details, Name attribute in the controller tag and content of the label and value tags. So I tried as follows,</p>
  
  <pre><code>FileInputStream fis = new FileInputStream("test.xml");
          Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(fis);
          Node objects = doc.getDocumentElement();
          for (Node object = objects.getFirstChild(); object != null; object = object.getNextSibling()) {
              if (object instanceof Element) {
                  Element e = (Element)object;
                  System.out.println(e.getTagName());
                  if (e.getTagName().equalsIgnoreCase("control")) {
                      String name = e.getAttribute("name");
                      System.out.println("It's a " + name + " control!");
                  } 
                 else {
                    System.out.println("I don't know what a " + e.getTagName() + " is for.");
                  }
              }
          }
  </code></pre>
  
  <p>With above code I am able to get the name attribute in the controller tag. Now how can I get the content of label and value tags.</p>
  
  <p>I need the following output,</p>
  
  <pre><code>name: first-name
  label: First Name
  value: Rahul
  
  
  name: last-name
  label: Last Name
  value: Sharma
  </code></pre>