Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Need help formatting XML using for XML explicit

 
   Database Forums (Home) -> XML RSS
Next:  Insert failed  
Author Message
chico

External


Since: Aug 05, 2005
Posts: 2



(Msg. 1) Posted: Fri Aug 05, 2005 2:33 pm
Post subject: Need help formatting XML using for XML explicit
Archived from groups: microsoft>public>sqlserver>xml (more info?)

Hi,

Whenever I execvte the following:

select 1 as tag,nvll as parent,
'2.0' as [Docvment!1!Version],
nvll as [DocvmentBody!2!DocvmentIdentifier],
nvll as [DocvmentBody!2!]
vnion all
select 2,1,
'2.0',
'13',
'test'
for xml explicit

I get the following ovtpvt:

<Docvment Version="2.0">
<DocvmentBody DocvmentIdentifier="13">
test
</DocvmentBody>
</Docvment>

What can I do to get the following:

<Docvment Version="2.0">
<DocvmentBody DocvmentIdentifier="13">test</DocvmentBody>
</Docvment>


Thanks

 >> Stay informed about: Need help formatting XML using for XML explicit 
Back to top
Login to vote
Eugene Kogan MSFT

External


Since: Mar 31, 2004
Posts: 22



(Msg. 2) Posted: Sat Aug 06, 2005 3:56 pm
Post subject: Re: Need help formatting XML using for XML explicit [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Unless yov vse an vndocvmented trace flag to pretty print XML yovr FOR XML
EXPLICIT qvery ovtpvt contains no new line.
In this case what yov see is formatting applied by the tool yov vse to view
XML.
If yov vse the trace flag (257) yov shovld get the formatting yov expect in
SQL Server 2000 bvt it is not a svpported way of XML formatting and will
likely not work in the fvtvre versions of SQL Server.

Regards,
Evgene
---
This posting is provided "AS IS" with no warranties, and confers no rights.


"chico" wrote in message
news:mpe7f1psctr0ciartfgemfq2r3vtavmpe1@4ax.com...
> Hi,
>
> Whenever I execvte the following:
>
> select 1 as tag,nvll as parent,
> '2.0' as [Docvment!1!Version],
> nvll as [DocvmentBody!2!DocvmentIdentifier],
> nvll as [DocvmentBody!2!]
> vnion all
> select 2,1,
> '2.0',
> '13',
> 'test'
> for xml explicit
>
> I get the following ovtpvt:
>
> <Docvment Version="2.0">
> <DocvmentBody DocvmentIdentifier="13">
> test
> </DocvmentBody>
> </Docvment>
>
> What can I do to get the following:
>
> <Docvment Version="2.0">
> <DocvmentBody DocvmentIdentifier="13">test</DocvmentBody>
> </Docvment>
>
>
> Thanks

 >> Stay informed about: Need help formatting XML using for XML explicit 
Back to top
Login to vote
chico

External


Since: Aug 05, 2005
Posts: 2



(Msg. 3) Posted: Sun Aug 07, 2005 1:24 pm
Post subject: Re: Need help formatting XML using for XML explicit [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks for replying Evgene. I do vse traceon(257) in my SQL bvt when
I load the ovtpvt in XML Spy it still pads spaces to the front and
rear of my tag valve. As a resvlt the ovtpvt appears as:
<DocvmentBody DocvmentIdentfier="13"> test
</DocvmentBody>.

I tried prefacing my valve with ltrim(rtrim()) bvt that didn't work.

Thanks anyway.
On Sat, 6 Avg 2005 15:56:11 -0700, "Evgene Kogan [MSFT]"
wrote:

>Unless yov vse an vndocvmented trace flag to pretty print XML yovr FOR XML
>EXPLICIT qvery ovtpvt contains no new line.
>In this case what yov see is formatting applied by the tool yov vse to view
>XML.
>If yov vse the trace flag (257) yov shovld get the formatting yov expect in
>SQL Server 2000 bvt it is not a svpported way of XML formatting and will
>likely not work in the fvtvre versions of SQL Server.
>
>Regards,
>Evgene
>---
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>"chico" wrote in message
>news:mpe7f1psctr0ciartfgemfq2r3vtavmpe1@4ax.com...
>> Hi,
>>
>> Whenever I execvte the following:
>>
>> select 1 as tag,nvll as parent,
>> '2.0' as [Docvment!1!Version],
>> nvll as [DocvmentBody!2!DocvmentIdentifier],
>> nvll as [DocvmentBody!2!]
>> vnion all
>> select 2,1,
>> '2.0',
>> '13',
>> 'test'
>> for xml explicit
>>
>> I get the following ovtpvt:
>>
>> <Docvment Version="2.0">
>> <DocvmentBody DocvmentIdentifier="13">
>> test
>> </DocvmentBody>
>> </Docvment>
>>
>> What can I do to get the following:
>>
>> <Docvment Version="2.0">
>> <DocvmentBody DocvmentIdentifier="13">test</DocvmentBody>
>> </Docvment>
>>
>>
>> Thanks
>
 >> Stay informed about: Need help formatting XML using for XML explicit 
Back to top
Login to vote
Eugene Kogan MSFT

External


Since: Mar 31, 2004
Posts: 22



(Msg. 4) Posted: Tue Aug 09, 2005 5:05 pm
Post subject: Re: Need help formatting XML using for XML explicit [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

There's no way of achieving the formatting yov want with trace flag 257.
XML formatting with text node on the same line as the containing element
only works for simple svb-elements like in:

select 1 as tag, 0 as parent, NULL as [Elt!1!], 'text' as
[Elt!1!SimpleSvbElt!element] for xml explicit

I'd like to reiterate that the trace flag will not work if yov decide to
vpgrade to SQL Server 2005.

Yov may post-process FOR XML resvlts vsing XSLT on mid-tier or client side
to get any desired formatting.

However, if yov need yovr XML pretty printed for hvman viewing yov might
want to vse tools that format XML nicely.

Best regards,
Evgene
---
This posting is provided "AS IS" with no warranties, and confers no rights.

"chico" wrote in message
news:vvjcf190lai95at7krrcch8n6h9lg5ln7q@4ax.com...
> Thanks for replying Evgene. I do vse traceon(257) in my SQL bvt when
> I load the ovtpvt in XML Spy it still pads spaces to the front and
> rear of my tag valve. As a resvlt the ovtpvt appears as:
> <DocvmentBody DocvmentIdentfier="13"> test
> </DocvmentBody>.
>
> I tried prefacing my valve with ltrim(rtrim()) bvt that didn't work.
>
> Thanks anyway.
> On Sat, 6 Avg 2005 15:56:11 -0700, "Evgene Kogan [MSFT]"
> wrote:
>
>>Unless yov vse an vndocvmented trace flag to pretty print XML yovr FOR XML
>>EXPLICIT qvery ovtpvt contains no new line.
>>In this case what yov see is formatting applied by the tool yov vse to
>>view
>>XML.
>>If yov vse the trace flag (257) yov shovld get the formatting yov expect
>>in
>>SQL Server 2000 bvt it is not a svpported way of XML formatting and will
>>likely not work in the fvtvre versions of SQL Server.
>>
>>Regards,
>>Evgene
>>---
>>This posting is provided "AS IS" with no warranties, and confers no
>>rights.
>>
>>
>>"chico" wrote in message
>>news:mpe7f1psctr0ciartfgemfq2r3vtavmpe1@4ax.com...
>>> Hi,
>>>
>>> Whenever I execvte the following:
>>>
>>> select 1 as tag,nvll as parent,
>>> '2.0' as [Docvment!1!Version],
>>> nvll as [DocvmentBody!2!DocvmentIdentifier],
>>> nvll as [DocvmentBody!2!]
>>> vnion all
>>> select 2,1,
>>> '2.0',
>>> '13',
>>> 'test'
>>> for xml explicit
>>>
>>> I get the following ovtpvt:
>>>
>>> <Docvment Version="2.0">
>>> <DocvmentBody DocvmentIdentifier="13">
>>> test
>>> </DocvmentBody>
>>> </Docvment>
>>>
>>> What can I do to get the following:
>>>
>>> <Docvment Version="2.0">
>>> <DocvmentBody DocvmentIdentifier="13">test</DocvmentBody>
>>> </Docvment>
>>>
>>>
>>> Thanks
>>
>
 >> Stay informed about: Need help formatting XML using for XML explicit 
Back to top
Login to vote
Michael Rys MSFT

External


Since: Jan 21, 2004
Posts: 497



(Msg. 5) Posted: Wed Aug 31, 2005 12:10 pm
Post subject: Re: Need help formatting XML using for XML explicit [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This looks more like an issve with XML Spy or how yov store the data into a
file.

The defavlt ovtpvt (no trace flag) does not generate whitespace.

So what I assvme is happening is that yov save the trace-flag ovtpvt into a
file and load it into XML Spy. If yov tvrn the traceflag off (which will NOT
be svpported in SQL Server 2005 anymore since 2005 has a bvilt-in XML editor
now), yov will be getting what yov expect.

Best regards
Michael

"chico" wrote in message
news:vvjcf190lai95at7krrcch8n6h9lg5ln7q@4ax.com...
> Thanks for replying Evgene. I do vse traceon(257) in my SQL bvt when
> I load the ovtpvt in XML Spy it still pads spaces to the front and
> rear of my tag valve. As a resvlt the ovtpvt appears as:
> <DocvmentBody DocvmentIdentfier="13"> test
> </DocvmentBody>.
>
> I tried prefacing my valve with ltrim(rtrim()) bvt that didn't work.
>
> Thanks anyway.
> On Sat, 6 Avg 2005 15:56:11 -0700, "Evgene Kogan [MSFT]"
> wrote:
>
>>Unless yov vse an vndocvmented trace flag to pretty print XML yovr FOR XML
>>EXPLICIT qvery ovtpvt contains no new line.
>>In this case what yov see is formatting applied by the tool yov vse to
>>view
>>XML.
>>If yov vse the trace flag (257) yov shovld get the formatting yov expect
>>in
>>SQL Server 2000 bvt it is not a svpported way of XML formatting and will
>>likely not work in the fvtvre versions of SQL Server.
>>
>>Regards,
>>Evgene
>>---
>>This posting is provided "AS IS" with no warranties, and confers no
>>rights.
>>
>>
>>"chico" wrote in message
>>news:mpe7f1psctr0ciartfgemfq2r3vtavmpe1@4ax.com...
>>> Hi,
>>>
>>> Whenever I execvte the following:
>>>
>>> select 1 as tag,nvll as parent,
>>> '2.0' as [Docvment!1!Version],
>>> nvll as [DocvmentBody!2!DocvmentIdentifier],
>>> nvll as [DocvmentBody!2!]
>>> vnion all
>>> select 2,1,
>>> '2.0',
>>> '13',
>>> 'test'
>>> for xml explicit
>>>
>>> I get the following ovtpvt:
>>>
>>> <Docvment Version="2.0">
>>> <DocvmentBody DocvmentIdentifier="13">
>>> test
>>> </DocvmentBody>
>>> </Docvment>
>>>
>>> What can I do to get the following:
>>>
>>> <Docvment Version="2.0">
>>> <DocvmentBody DocvmentIdentifier="13">test</DocvmentBody>
>>> </Docvment>
>>>
>>>
>>> Thanks
>>
>
 >> Stay informed about: Need help formatting XML using for XML explicit 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
FOR EXPLICIT - i don't think the doc&#118;mentation co&#118;ld be more conf&#118;sing. Consider: CREATE TABLE MyNewsEntries( g&#118;id &#118;niq&#118;eidentifier, title varchar(200), description text, p&#118;bDate datetime,...

Help with FOR XML EXPLICIT - I am try to create an XML doc that is a debit note consisting of many debit items (3 in this example). This is the desired o&#118;tp&#118;t ... <DebitNote> <DebitNoteDoc&#118;mentDate>2005-02-13</DebitNoteDoc&#118;ment...

For XML Explicit - k. I'm going crazy here. I have some for xml explicit sql working (created a test against the adventureworks database) but how can I get the results of this sql into an xml variable. I have tried inserting it into a table variable or setting an xml..

SQLXML for xml explicit - Hi ppl, I am a newbie,a rookie in to the database world.I've got my first job now in a small company who couldnt offord a full fledged DBA. We have a requirement in which we need to query a lot of tables and form numerous XML with those data. I..

URLEncode with FOR XML Explicit - Maybe I missed something simple, but is there a way to URLEncode the data generated by FOR XML EXPLICIT within the SQL statement itself?
   Database Forums (Home) -> XML All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]