title: Reading XML tags getting value from inner tag
body: <p>I don't know how to explain my situation, I can provide example below. 
  I have an XML file to be read in Java, something like this:</p>
  
  <pre><code>&lt;Author AffiliationIDS="Aff1"&gt;
      &lt;AuthorName DisplayOrder="Western"&gt;
         &lt;GivenName&gt;Wei&lt;/GivenName&gt;
         &lt;GivenName&gt;Long&lt;/GivenName&gt;
         &lt;FamilyName&gt;
         &lt;Value&gt;Tan&lt;/Value&gt;
         &lt;/FamilyName&gt;
      &lt;/AuthorName&gt;
  &lt;/Author&gt;
  </code></pre>
  
  <p>As you can see the <code>&lt;FamilyName&gt;</code> tag, inside the <code>&lt;FamilyName&gt;</code> tag is surrounded by a Value tag. This is because in the xsd it stated the element as <code>maxOccurs="unbounded"</code> which mean more than one value can be in that element tag. How should I modify the code so that it can read in the <code>&lt;FamilyName&gt;</code> tag and get <code>Value</code> tag element no matter how many occurrence of the <code>Value</code> exist?</p>
  
  <p>Example:</p>
  
  <pre><code>           &lt;FamilyName&gt;
             &lt;Value&gt;Sarah&lt;/Value&gt;
             &lt;Value&gt;Johnson&lt;/Value&gt;
             &lt;/FamilyName&gt;
  </code></pre>
  
  <p>The code look like this.</p>
  
  <pre><code>import javax.xml.parsers.DocumentBuilderFactory;
  import javax.xml.parsers.DocumentBuilder;
  import org.w3c.dom.Document;
  import org.w3c.dom.NodeList;
  import org.w3c.dom.Node;
  import org.w3c.dom.Element;
  import java.io.File;
  
  public class ReadXMLFile {
  
    public static void main(String argv[]) {
  
          try {
  
          File fXmlFile = new File("/fileaddress/test-1.xml");
          DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
          Document doc = dBuilder.parse(fXmlFile);
  
  
          doc.getDocumentElement().normalize();
  
          System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
  
          NodeList nList = doc.getElementsByTagName("AuthorName");
  
          System.out.println("----------------------------");
  
          for (int temp = 0; temp &lt; nList.getLength(); temp++) {
  
              Node nNode = nList.item(temp);
  
              System.out.println("\nCurrent Element :" + nNode.getNodeName());
  
              if (nNode.getNodeType() == Node.ELEMENT_NODE) {
  
                  Element eElement = (Element) nNode;
  
                  System.out.println("Given Name : " + eElement.getElementsByTagName("GivenName").item(0).getTextContent());
                  System.out.println("Family Name : " + eElement.getElementsByTagName("FamilyName").item(0).getTextContent());
  
              }
          }
          } catch (Exception e) {
          e.printStackTrace();
          }
        }
  
  }
  </code></pre>