Helzz help me on Query For XML

Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 7
Reputation: Ninad is an unknown quantity at this point 
Solved Threads: 0
Ninad's Avatar
Ninad Ninad is offline Offline
Newbie Poster

Helzz help me on Query For XML

 
0
  #1
Sep 20th, 2007
I've following database structure (just junk values)

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1.  
  2. [ChannelID] [ChannelName] [ChannelCatID] [RSSFeedURL]
  3. 1 YouTube 1 ret
  4. 2 GoogleVideo 1 ert
  5. 3 MSNVideo 1 rtertert
  6. 4 ABC 2 retert
  7. 5 YahooVideo 1 erter
  8. 6 CBS 2 rtr
  9. 7 NBC 2 trtrt
  10. 8 ESPN 2 rt
  11. 9 FOX 2 rtrtttr
  12. 10 AOL 1 rt

I wanna generate following XML structure out of it

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. - <DOC>
  2. - <Item Type="xyz">
  3. - <Channel id="a">
  4. <Name>aaaaa<Name/>
  5. <URL>aaaaa<URL/>
  6. </Channel>
  7.  
  8. - <Channel id="b">
  9. <Name>bbbb<Name/>
  10. <URL>bbbb<URL/>
  11. </Channel>
  12. ---
  13. ---
  14. </Item>
  15.  
  16. - <Item Type="lmn">
  17. - <Channel id="x">
  18. <Name>xxxx<Name/>
  19. <URL>xxxx<URL/>
  20. </Channel>
  21.  
  22. - <Channel id="y">
  23. <Name>yyyy<Name/>
  24. <URL>yyyy<URL/>
  25. </Channel>
  26. ---
  27. ---
  28. </Item>
  29. ------
  30. ------
  31. ------
  32. </DOC>


I 've written this Select For XML query

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. SELECT ChannelCatID as '@type',
  2. ChannelID as 'Channel/@id',
  3. ChannelName as 'Channel/Name',
  4. RSSFeedURL as 'Channel/URL'
  5. FROM ChannelMaster
  6. FOR XML PATH('Item'), ROOT('DOC')

It gives me this result

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. - <DOC>
  2. - <Item Type="xyz">
  3. - <Channel id="a">
  4. <Name>aaaaa<Name/>
  5. <URL>aaaaa<URL/>
  6. </Channel>
  7. </Item>
  8. - <Item Type="xyz">
  9. - <Channel id="b">
  10. <Name>bbbb<Name/>
  11. <URL>bbbb<URL/>
  12. </Channel>
  13. </Item>
  14. - <Item Type="xyz">
  15. ---
  16. </Item>
  17. - <Item Type="xyz">
  18. ---
  19. </Item>
  20. ------
  21. ------
  22. ------
  23. </DOC>



I want it this way:
all channels of Type xyz should come under singe <Item Type="xyz"> tag
instead of seperate tags
what changes should i make ??
Last edited by Ninad; Sep 20th, 2007 at 3:28 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 160
Reputation: kb.net is an unknown quantity at this point 
Solved Threads: 26
kb.net's Avatar
kb.net kb.net is offline Offline
Junior Poster

Re: Helzz help me on Query For XML

 
0
  #2
Sep 20th, 2007
Hi,
Try adding this to the end of the query:
"group By Item Type"
It is never about the number of languages you know, you either have the logic of programming or you don't ...

Some of the codes I post are collected from different sites during the past couple of years, so I would like to thank them for their help and for enabling me to help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the XML, XSLT and XPATH Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC