title: XQuery - Join query
body: <p>I have two XML files and want to join them to get the desired output.</p>
  
  <p>XML File -1 </p>
  
  <pre><code>&lt;Countries&gt;
  &lt;Country&gt;
     &lt;No C="1"/&gt;
     &lt;Name&gt;India&lt;/Name&gt;
  &lt;/Country&gt;
  &lt;Country&gt;
     &lt;No C="2"/&gt;
     &lt;Name&gt;USA&lt;/Name&gt;
  &lt;/Country&gt;
  &lt;Country&gt;
     &lt;No C="3"/&gt;
     &lt;Name&gt;Srilanka&lt;/Name&gt;
  &lt;/Country&gt;
  &lt;Country&gt;
     &lt;No C="4"/&gt;
     &lt;Name&gt;Thailand&lt;/Name&gt;
  &lt;/Country&gt;
  &lt;/Countries&gt;
  </code></pre>
  
  <p>XML File - 2</p>
  
  <pre><code>&lt;Capitals&gt;
    &lt;Capital&gt;
        &lt;No C="1"/&gt;
        &lt;Name&gt;New Delhi&lt;/Name&gt;
    &lt;/Capital&gt;
    &lt;Capital&gt;
        &lt;No C="2"/&gt;
        &lt;Name&gt;Washington DC&lt;/Name&gt;
    &lt;/Capital&gt;
    &lt;Capital&gt;
        &lt;No C="3"/&gt;
        &lt;Name&gt;Colombo&lt;/Name&gt;
    &lt;/Capital&gt;
    &lt;Capital&gt;
        &lt;No C="4"/&gt;
        &lt;Name&gt;Bangkok&lt;/Name&gt;
    &lt;/Capital&gt;
  &lt;/Capitals&gt;
  </code></pre>
  
  <p>Output desired - </p>
  
  <pre><code>India - New Delhi
  USA - Washington DC
  Srilanka - Colombo
  Thailand - Bangkok
  </code></pre>
  
  <p>What I have tried is like, but unable to get the desired output :(</p>
  
  <pre><code>for $x in doc('Country')/Countries
    return 
    &lt;a&gt;
   {$x/Country/Name}
   {
     for $y in doc('Capital')/Capitals
     where $y/Capital/No/@C = $x/Country/No/@C
      return $y/Capital/Name
    }
    &lt;/a&gt;
  </code></pre>