<div>Hi All,</div>
<div> </div>
<div>I wrote one XQuery it&#39;s work but taking time I want to optimize time taken by that XQuery.</div>
<div>Here I explaine a brief scenario.</div>
<div>There are two diff xml files. I need to check first xml file&#39;s tag&#39;s attributes value and check it into second file</div>
<div>If this value is same than I need to go forward for more process.</div>
<div>I used for loop for it but it takes time so how can I optimize time in this case.</div>
<div> </div>
<div>here is example</div>
<div> </div>
<div><strong><font size="4">First XML file</font></strong></div>
<div> </div>
<div>&lt;?xml version=&quot;1.0&quot; encoding=&quot;US-ASCII&quot;?&gt;<br>&lt;doc1&gt;<br>&lt;info id=&quot;1&quot;&gt;<br>&lt;fname&gt;Kunal&lt;/fname&gt;<br>&lt;lname&gt;chauhan&lt;/lname&gt;<br>&lt;/info&gt;<br>&lt;info id=&quot;2&quot;&gt;<br>
&lt;fname&gt;Bhavik&lt;/fname&gt;<br>&lt;lname&gt;Solanki&lt;/lname&gt;<br>&lt;/info&gt;<br>&lt;info id=&quot;3&quot;&gt;<br>&lt;fname&gt;Geet&lt;/fname&gt;<br>&lt;lname&gt;Gangwar&lt;/lname&gt;<br>&lt;/info&gt;<br>&lt;/doc1&gt;</div>

<div> </div>
<div> </div>
<div><strong><font size="4">Second XML file</font></strong></div>
<div> </div>
<div>&lt;?xml version=&quot;1.0&quot; encoding=&quot;US-ASCII&quot;?&gt;<br>&lt;Doc2&gt;<br>&lt;empinfo id=&quot;1&quot;&gt;<br>&lt;name&gt;Kunal&lt;/name&gt;<br>&lt;dept&gt;tech&lt;/dept&gt;<br>&lt;roll&gt;prog&lt;/roll&gt;<br>
&lt;/empinfo&gt;<br>&lt;empinfo id=&quot;2&quot;&gt;<br>&lt;name&gt;Bhavik&lt;/name&gt;<br>&lt;dept&gt;tech&lt;/dept&gt;<br>&lt;roll&gt;prog&lt;/roll&gt;<br>&lt;/empinfo&gt;<br>&lt;empinfo id=&quot;3&quot;&gt;<br>&lt;name&gt;Geet&lt;/name&gt;<br>
&lt;dept&gt;tech&lt;/dept&gt;<br>&lt;roll&gt;tl&lt;/roll&gt;<br>&lt;/empinfo&gt;<br>&lt;/Doc2&gt;</div>
<div> </div>
<div><strong><font size="4">XQuery</font></strong></div>
<div> </div>
<div><span class="c9Y6TC"><font color="#0000ff">let</font></span> $d1 <span class="c50HZ4"><font color="#008080">:=</font></span> doc(<span class="c4ZSSG"><font color="#800080">&quot;D:/xbrl/NewDoc1.xml&quot;</font></span>)<br>
<span class="c9Y6TC"><font color="#0000ff">let</font></span> $d2 <span class="c50HZ4"><font color="#008080">:=</font></span> doc(<span class="c4ZSSG"><font color="#800080">&quot;D:/xbrl/NewDoc2.xml&quot;</font></span>)<br>
<br><span class="c9Y6TC"><font color="#0000ff">for</font></span> $x <span class="c9Y6TC"><font color="#0000ff">in</font></span> $d1,$y <span class="c9Y6TC"><font color="#0000ff">in</font></span> $d2<br><font color="#0000ff">check</font> ($x/doc1/info/@id <span class="c50HZ4"><font color="#008080">=</font></span> $y/Doc2/empinfo/<span class="c9Y6TC"><font color="#0000ff">attribute::</font></span>id)   // check ids of each node and if they are same than process forward</div>

<div>...</div>
<div>...</div>
<div>..<br><span class="c9Y6TC"><font color="#0000ff">return</font></span> $y/Doc2/empinfo/name </div>
<div> </div>
<div>in this example I just return name but actualyy if ids are same than I need to go forward and do some more process and after that return final result.</div>
<div>so is there any other way, other than for loop</div>
<div> </div>
<div> </div>
<div>Thanks &amp; Regards,<br clear="all"><br></div>
<div style="TEXT-ALIGN: left"><font color="#9999ff"><strong>Kunal Chauhan</strong></font></div>
<div style="TEXT-ALIGN: left"><a href="mailto:mail4ck@gmail.com" target="_blank"><font color="#9999ff">mail4ck@gmail.com</font></a></div>
<div style="TEXT-ALIGN: left"><font color="#9999ff">[+918655517141]</font></div>
<div style="TEXT-ALIGN: left"><font color="#9999ff">[+919904983614]</font></div><br>