dbTalk Databases Forums  

FOR XML PATH and empty list

microsoft.public.sqlserver.xml microsoft.public.sqlserver.xml


Discuss FOR XML PATH and empty list in the microsoft.public.sqlserver.xml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Miroo
 
Posts: n/a

Default FOR XML PATH and empty list - 12-15-2008 , 02:10 AM






Hi
I'm simply listing records from a database into such xml:
<LIST>
<ITEM id=1" />
<ITEM id=2" />
...
</LIST>

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
<LIST />

How to achieve it in FOR XML PATH mode?

--
Regards
Miroo

Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM






Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #3  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #4  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #5  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #6  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #7  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #8  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #9  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #10  
Old   
Martin Honnen
 
Posts: n/a

Default Re: FOR XML PATH and empty list - 12-15-2008 , 06:22 AM



Miroo wrote:

Quote:
I'm simply listing records from a database into such xml:
LIST
ITEM id=1" /
ITEM id=2" /
...
/LIST

I was using FOR XML EXPLICIT for that but now I'd like to do it
using more friendly FOR XML PATH mode. The problem is that if there is
no records in the list it returns empty XML. In FOR XML EXPLICIT mode
it returned empty element.
LIST /

How to achieve it in FOR XML PATH mode?
Does

FOR XML PATH, ROOT('LIST')

do what you want? If not then you need to tell us more about your
table(s) you want to query.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.