本文介绍了XML生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面有表格结构


< pre> USE [MOSS_Sample] GO
/******对象:表格[dbo].[TT_FORMS_ASSIGIN]脚本日期:2010年10月30日10:28:06 ******/
设置ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
设置ANSI_PADDING ON
GO
创建表[dbo].[TT_FORMS_ASSIGIN]([MAIN_ID] [int]不为空,[SUB_ID] [int]不为空,[FORM_ID] [int]不为空,[FORM_NAME] [nvarchar](50)收集SQL_Latin1_General_CP1_CI_AS NULL, [FORM_HEADER] [nvarchar](50)收集SQL_Latin1_General_CP1_CI_AS NULL,[FORM_PATH] [nvarchar](50)收集SQL_Latin1_General_CP1_CI_AS NULL,[READ_WRITE] [字符](1)COLLATE SQL_Latin1_General_NULL,[INT_ID, ] [nvarchar](50)收集SQL_Latin1_General_CP1_CI_AS NULL,[INSERTED_BY] [nvarchar](50)收集SQL_Latin1_General_CP1_CI_AS NULL,[INSERTED_DATE] [datetime] NULL,[MODEFIED_BY] [nvarchar_ED_ [ATE1] ] NULL,约束[PK_TT_FORMS_ASSIGIN]主键已聚集
([MAIN_ID] ASC,[SUB_ID] ASC,[FORM_ID] ASC,[ROLE_ID] ASC
)与(IGNORE_DUP_KEY = OFF)开启[PRIMARY])开启[PRIMARY] GO
设置ANSI_PADDING OFF
</pre>


我需要将上面的表格转换为下面的xml格式

XML示例:


< root>
< type value =管理员">
< ActionType value =大师">
< ActionItem value =总部" url =〜/Master/HeadOffice.aspx" displayText =总部">
</ActionItem>
< ActionItem value =区域办公室" url =〜/Master/HeadOffice.aspx" displayText ="HeadOffice">
</ActionItem>
</ActionType>
< ActionType value =贷款">
< ActionItem value ="BulkLoans" url =〜/Loans/BulkLoans.aspx" displayText ="BulkLoans">
</ActionItem>
< ActionItem value ="MemberApplication" url =〜/Loans/MemberApplication.aspx" displayText ="MemberApplication">
</ActionItem>
</ActionType>
</type>
</root>
在下面的句子中,使您无法理解基于三列组合生成xml的问题.
正在解释生成xml所需的格式

如果该组合xml主节点的列值(mainId,SubId,FormId)=(1,0,0)应该在此表格中,则该表格位于表格上方

< type value ="Administrator>
组合xml中间节点的if(maiId,SubId,FormId)=(1,1,0)应该在此formate
< ActionType value =大师">
组合xml内部节点的if(maiId,SubId,FormId)= {1,1,1)应该在此格式中
< actionitem value =总部" url =〜/Master/HeadOffice.aspx" displaytext =总部">
标签(bulkLoans)
url和displayname来自表if(1,1,1)

我需要明智地在上述组合中生成所有xml

form_header将给出值

I have a table stucture in below


<pre> USE [MOSS_Sample]GO
/****** Object: Table [dbo].[TT_FORMS_ASSIGIN] Script Date: 10/30/2010 10:28:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TT_FORMS_ASSIGIN]( [MAIN_ID] [int] NOT NULL, [SUB_ID] [int] NOT NULL, [FORM_ID] [int] NOT NULL, [FORM_NAME] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [FORM_HEADER] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [FORM_PATH] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [READ_WRITE] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [ROLE_ID] [int] NOT NULL, [ICON_PATH] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [INSERTED_BY] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [INSERTED_DATE] [datetime] NULL, [MODEFIED_BY] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [MODEFIED_DATE] [datetime] NULL, CONSTRAINT [PK_TT_FORMS_ASSIGIN] PRIMARY KEY CLUSTERED
( [MAIN_ID] ASC, [SUB_ID] ASC, [FORM_ID] ASC, [ROLE_ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]GO
SET ANSI_PADDING OFF
</pre>


I need to convert above table in to below xml format

XML Example:


<root >
<type value="Administrator">
<ActionType value="Masters">
<ActionItem value="Head Office" url="~/Master/HeadOffice.aspx" displayText="Head Office" >
</ActionItem>
<ActionItem value="Area Office" url="~/Master/HeadOffice.aspx" displayText="HeadOffice">
</ActionItem>
</ActionType>
<ActionType value="Loans">
<ActionItem value="BulkLoans" url="~/Loans/BulkLoans.aspx" displayText="BulkLoans" >
</ActionItem>
<ActionItem value="MemberApplication" url="~/Loans/MemberApplication.aspx" displayText="MemberApplication">
</ActionItem>
</ActionType>
</type>
</root >
in below following sentences make u underrstant my problem in generating xml based on three column combination .
am explaning the formate which i need for generating xml

inabove table if column values (mainId,SubId,FormId)=(1,0,0) for this combination xml main node should be in this formate

<type value="Administrator>
if(maiId,SubId,FormId)=(1,1,0) for combination xml Middle node should be in this formate
<ActionType value="Masters">
if(maiId,SubId,FormId)=(1,1,1) for combination xml inner node should be in this formate
<actionitem value="Head Office" url="~/Master/HeadOffice.aspx" displaytext="Head Office">
tag (bulkLoans)
url and displayname come from table if(1,1,1)

i nead to generate all xml in above combinations wise

form_header will give value

推荐答案


这篇关于XML生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 00:29