通过Sql语句直接返回XML文件

 

select UserID,UserName,AccountName,LoginPassword from users for xml raw('Users') ,root ('User') 
--Users为子节点名称  User为根节点名称

生产文件格式如下

<User>
  <Users UserID="88103" UserName="Manager" AccountName="adminManager" LoginPassword="123456" />
  <Users UserID="88104" UserName="Manager1" AccountName="Manager1" LoginPassword="123456" />
  <Users UserID="88569" UserName="鄢树岭" AccountName="yansl@nmg" LoginPassword="11111111" />
  <Users UserID="88570" UserName="塔娜" AccountName="tan_dcs@nmg" LoginPassword="11111111" />
  <Users UserID="88571" UserName="鹿传深" AccountName="lucs@nmg" LoginPassword="11111111" />
  <Users UserID="88572" UserName="钱英" AccountName="qiany_lgb@nmg" LoginPassword="11111111" />
  <Users UserID="88573" UserName="陈旭呈" AccountName="chenxc@nmg" LoginPassword="11111111" />
</User>

 

posted on 2013-08-17 21:29  高兴happy  阅读(1135)  评论(0编辑  收藏  举报