比如把SQL查询的结果输出成如下XML格式的内容:
<DocumentElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <table> <字段1>1</字段1> <字段2>测试</字段2> </table> <table> <字段1>2</字段1> <字段2>测试2</字段2> </table></DocumentElement>
语句为:select 字段1,字段2 from 表 for xml path('table'),ROOT('DocumentElement'), ELEMENTS XSINIL