title: T-SQL Question : Query to XML
body: <p>anyone can show me how to generate from this data</p>
  
  <pre><code>------------------------DATA--------------------------
  
  Key ParentKey
  5 NULL
  25 5
  33 25
  26 5
  27 5
  34 27
  28 5
  29 5
  </code></pre>
  
  <p>to this XML result?</p>
  
  <pre><code>---------------------RESULTS--------------------------
  
      &lt;record key="5" parentkey = ""&gt;
       &lt;record key="25" parentkey = "5"&gt;
        &lt;record key="33" parentkey = "25"&gt;&lt;/record&gt;
        &lt;/record&gt;
       &lt;/record&gt;
       &lt;record key="25" parentkey = "5"&gt;
       &lt;record key="26" parentkey = "5"&gt;
       &lt;record key="27" parentkey = "5"&gt;
        &lt;record key="34" parentkey = "27"&gt;&lt;/record&gt;
        &lt;/record&gt;
       &lt;/record&gt;
       &lt;record key="28" parentkey = "5"&gt;
       &lt;record key="29" parentkey = "5"&gt;
      &lt;/record&gt;
  </code></pre>