[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Position Complex Elements w/ For XML Explicit

creed1

3/16/2007 12:57:00 AM

I need to generate an XML document that takes the following format. The
format has already been defined by a separate application.

<Opportunity>
<Name>Example Name</Name>
<Customer Id="A">
<Name>Some Customer</Name>
</Customer>
<TotalValue>50.000</TotalValue>
</Opportunity>

My query would look something like this...

select
1 as Tag,
0 as Parent,
name as [Opportunity!1!Name!element],
custid as [Customer!2!Id],
custname as [Customer!2!Name!element],
totval as [Opportunity!1!TotalValue!element]
....

I can't seem to get the Customer element in the correct position. It always
seems to float to the bottom of the document before the </Opportunity> tag.
Can FOR XML EXPLICIT be used to generate this document?
1 Answer

xyb

3/16/2007 2:23:00 AM

0

On 3?16?, ??8?57?, creed1 <cre...@discussions..microsoft.com> wrote:
> I need to generate an XML document that takes the following format. The
> format has already been defined by a separate application.
>
> <Opportunity>
> <Name>Example Name</Name>
> <Customer Id="A">
> <Name>Some Customer</Name>
> </Customer>
> <TotalValue>50.000</TotalValue>
> </Opportunity>
>
> My query would look something like this...
>
> select
> 1 as Tag,
> 0 as Parent,
> name as [Opportunity!1!Name!element],
> custid as [Customer!2!Id],
> custname as [Customer!2!Name!element],
> totval as [Opportunity!1!TotalValue!element]
> ...
>
> I can't seem to get the Customer element in the correct position. It always
> seems to float to the bottom of the document before the </Opportunity> tag.
> Can FOR XML EXPLICIT be used to generate this document?

I am sure,you need post your DDL :)