title: Java get XML nodes
body: <p>i want to get  the names of the first two Service Authors.</p>
  
  <p>i have the following XML example:</p>
  
  <pre><code>&lt;ServiceSchema:id&gt;10&lt;/ServiceSchema:id&gt;
  &lt;ServiceSchema:name&gt;Service 10&lt;/ServiceSchema:name&gt;
  &lt;ServiceSchema:authorInfos&gt;
      &lt;ServiceSchema:authorInfo&gt;
          &lt;ServiceSchema:id&gt;1&lt;/ServiceSchema:id&gt;
          &lt;ServiceSchema:name&gt;Service Author 1&lt;/ServiceSchema:name&gt;
      &lt;ServiceSchema:authorInfo&gt;
      &lt;ServiceSchema:authorInfo&gt;
          &lt;ServiceSchema:id&gt;2&lt;/ServiceSchema:id&gt;
          &lt;ServiceSchema:name&gt;Service Author 2&lt;/ServiceSchema:name&gt;
      &lt;ServiceSchema:authorInfo&gt;
  &lt;/ServiceSchema:authorInfos&gt;
  
  &lt;ServiceSchema:requirements&gt;
      &lt;ServiceSchema:requirement&gt;
          &lt;ServiceSchema:id&gt;1&lt;/ServiceSchema:id&gt;
          &lt;ServiceSchema:name&gt;Requirement 1&lt;/ServiceSchema:name&gt;
          &lt;ServiceSchema:authorInfos&gt;
              &lt;ServiceSchema:authorInfo&gt;
                  &lt;ServiceSchema:id&gt;5&lt;/ServiceSchema:id&gt;
                  &lt;ServiceSchema:name&gt; Requirement Author 5&lt;/ServiceSchema:name&gt;
              &lt;ServiceSchema:authorInfo&gt;
          &lt;/ServiceSchema:authorInfos&gt;
      &lt;/ServiceSchema:requirement&gt;
  .....
  </code></pre>
  
  <p>I can get all name nodes with the following code:</p>
  
  <pre><code>DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware(true);
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource inputSource = new InputSource(new ByteArrayInputStream (xml.getBytes("utf-8")));
  Document xmldocument = db.parse(inputSource);
  NodeList nodeList = xmldocument.getElementsByTagNameNS("*", "name");
  </code></pre>
  
  <p>But i don't know how to get only the names of the outer authors.</p>
  
  <p>Thank you.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>What I am trying to do completely is:
  I search different xml files for different nodes. The xml file above was meant as an example.</p>
  
  <p>For example:</p>
  
  <pre><code>searchElementsXml = new String[]{"name", "id", "version", "description", "keywords", "authorInfos.authorInfo.name", "status"};
  </code></pre>
  
  <p>I have some fields where many values ​​can occur. Like the author info.</p>
  
  <p>So i need something like:</p>
  
  <pre><code>NodeList nodes = doc.getElementsByTagName("ServiceSchema:authorInfos:authorinfo:name");
  </code></pre>
  
  <p>is there a good solution out there?</p>