title: Select parent and first child element which has more than one child element
body: <p>Query is to get the first child element with it's value where the corresponding parent element should have more than one child element.</p>
  
  <p>Here, tricky is issue is that parent and child element is generated dynamically. i.e. we doesn't know about the parent and child names</p>
  
  <p>Here is the XML Input:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;PageTwo&gt;
     &lt;List25&gt;No&lt;/List25&gt;
     &lt;List11&gt;Air Gun|Gun&lt;/List11&gt;
     &lt;Multilist02&gt;
      &lt;Value&gt;.204&lt;/Value&gt;
      &lt;Value&gt;.22&lt;/Value&gt;
      &lt;Value&gt;.243&lt;/Value&gt;
     &lt;/Multilist02&gt;
     &lt;Multilist05&gt;
      &lt;Value&gt;Air Gun|NOS|NOS&lt;/Value&gt;
      &lt;Value&gt;Optic|Binocular|ZULU5&lt;/Value&gt;
     &lt;/Multilist05&gt;
     &lt;List23&gt;DAK&lt;/List23&gt;
     &lt;Text01&gt;NA&lt;/Text01&gt;
     &lt;List13&gt;EA&lt;/List13&gt;
     &lt;List26&gt;No&lt;/List26&gt;
     &lt;List07&gt;IN&lt;/List07&gt;
     &lt;List08&gt;LB&lt;/List08&gt;
    &lt;/PageTwo&gt;  </code></pre>
  </div>
  </div>
  </p>
  
  <p>In the above XML, <strong>Multilist</strong> contains more than one child value and has to extract the first child element with Value</p>
  
  <p>Sample [Excepted] Output</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>            &lt;Multilist02&gt;
         &lt;Value&gt;.204&lt;/Value&gt;
     &lt;/Multilist02&gt;
     &lt;Multilist05&gt;
      &lt;Value&gt;Air Gun|NOS|NOS&lt;/Value&gt;
     &lt;/Multilist05&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>As I said before, in the incoming xml we doesn't know what name will come for parent and child element.</p>
  
  <p>I tried below XSLT and able to extract the first child but unable to cover the child with corresponding parent element</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.oracle.com/webfolder/technetwork/xml/plm/2014/08/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.oracle.com/webfolder/technetwork/xml/plm/2014/08/ http://www.oracle.com/webfolder/technetwork/xml/plm/2014/08/aXML.xsd"&gt;
  &lt;xsl:template match="/"&gt; 
  &lt;xsl:for-each select="/PageTwo/*"&gt;
  &lt;xsl:for-each select="*"&gt;
   &lt;xsl:variable name="i" select="position()" /&gt;
  &lt;xsl:if test="$i = 1"&gt;
  &lt;xsl:copy-of select="."/&gt;
  &lt;/xsl:if&gt;
  &lt;/xsl:for-each&gt;
  &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Generated Output is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Value&gt;.204&lt;/Value&gt;&lt;Value&gt;Air Gun|NOS|NOS&lt;/Value&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Kindly help me on this issue </p>
  
  <p><strong>EDIT:</strong> Below answer resolved above question which I accepted as answer</p>
  
  <p>Adding one more query on above XML Input file with adding attributes to root node.</p>
  
  <p><strong>New Input:</strong> Added attributes to root node</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;PageTwo  xmlns="http://www.oracle.com/webfolder/technetwork/xml/plm/2/2/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.oracle.com/webfolder/technetwork/xml/plm/2/2/ http://www.oracle.com/webfolder/technetwork/xml/plm/2/2/aXML.xsd" creator="admin, nawaz(nawaz)"&gt;
     &lt;List25&gt;No&lt;/List25&gt;
     &lt;List11&gt;Air Gun|Gun&lt;/List11&gt;
     &lt;Multilist02&gt;
      &lt;Value&gt;.204&lt;/Value&gt;
      &lt;Value&gt;.22&lt;/Value&gt;
      &lt;Value&gt;.243&lt;/Value&gt;
     &lt;/Multilist02&gt;
     &lt;Multilist05&gt;
      &lt;Value&gt;Air Gun|NOS|NOS&lt;/Value&gt;
      &lt;Value&gt;Optic|Binocular|ZULU5&lt;/Value&gt;
     &lt;/Multilist05&gt;
     &lt;List23&gt;DAK&lt;/List23&gt;
     &lt;Text01&gt;NA&lt;/Text01&gt;
     &lt;List13&gt;EA&lt;/List13&gt;
     &lt;List26&gt;No&lt;/List26&gt;
     &lt;List07&gt;IN&lt;/List07&gt;
     &lt;List08&gt;LB&lt;/List08&gt;
    &lt;/PageTwo&gt;  </code></pre>
  </div>
  </div>
  </p>
  
  <p>Suppose if I want parse the element with their name rather specifying <code>*</code> on the below solution which I accepted as answer</p>
  
  <p><strong>Current answer</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;xsl:template match="/"&gt;
    &lt;xsl:apply-templates select="*/*[*[2]]"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="*"&gt;
    &lt;xsl:copy&gt;
      &lt;xsl:copy-of select="@* | *[1]"/&gt;
    &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Even I am able to parse the elements by specifying their corresponding name when <strong>attributes are not present in the root node</strong>. But I would like to parse the element with their name with root node attributes to display</p>
  
  <p><strong>Excepted Solution</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;PageTwo xmlns="http://www.oracle.com/webfolder/technetwork/xml/plm/2/2/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.oracle.com/webfolder/technetwork/xml/plm/2/2/ http://www.oracle.com/webfolder/technetwork/xml/plm/2/2/aXML.xsd" creator="admin, nawaz(nawaz)"&gt;
    &lt;Multilist02&gt;
         &lt;Value&gt;.204&lt;/Value&gt;
    &lt;/Multilist02&gt;
    &lt;Multilist05&gt;
      &lt;Value&gt;Air Gun|NOS|NOS&lt;/Value&gt;
    &lt;/Multilist05&gt;
  &lt;/PageTwo&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>condition</strong> Parse the element with their names</p>