SQL2k8 T-SQL: Output into XML file
        Posted  
        
            by Nai
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Nai
        
        
        
        Published on 2010-05-26T18:30:05Z
        Indexed on 
            2010/05/26
            18:31 UTC
        
        
        Read the original article
        Hit count: 394
        
I have two tables
Table Name: Graph
UID1   UID2
----------- 
12     23 
12     32
41     51
32     41
Table Name: Profiles
NodeID UID  Name
-----------------
1      12   Robs
2      23   Jones
3      32   Lim
4      41   Teo
5      51   Zacks
I want to get an xml file like this:
<graph directed="0">
  <node id="1">
    <att name="UID"  value="12"/>
    <att name="Name" value="Robs"/>
  </node>
  <node id="2">
    <att name="UID" value="23"/>
    <att name="Name" value="Jones"/>
  </node>
  <node id="3">
    <att name="UID" value="32"/>
    <att name="Name" value="Lim"/>
  </node>
  <node id="4">
    <att name="UID" value="41"/>
    <att name="Name" value="Teo"/>
  </node>
  <node id="5">
    <att name="UID" value="51"/>
    <att name="Name" value="Zacks"/>
  </node>
  <edge source="12" target="23" /> 
  <edge source="12" target="32" /> 
  <edge source="41" target="51" /> 
  <edge source="32" target="41" /> 
</graph>
Thanks very much!
© Stack Overflow or respective owner