| | |
Helzz help me on Query For XML
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
![]() |
I've following database structure (just junk values)
I wanna generate following XML structure out of it
I 've written this Select For XML query
It gives me this result
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 ??
XML, XSLT and XPATH Syntax (Toggle Plain Text)
[ChannelID] [ChannelName] [ChannelCatID] [RSSFeedURL] 1 YouTube 1 ret 2 GoogleVideo 1 ert 3 MSNVideo 1 rtertert 4 ABC 2 retert 5 YahooVideo 1 erter 6 CBS 2 rtr 7 NBC 2 trtrt 8 ESPN 2 rt 9 FOX 2 rtrtttr 10 AOL 1 rt
I wanna generate following XML structure out of it
XML, XSLT and XPATH Syntax (Toggle Plain Text)
- <DOC> - <Item Type="xyz"> - <Channel id="a"> <Name>aaaaa<Name/> <URL>aaaaa<URL/> </Channel> - <Channel id="b"> <Name>bbbb<Name/> <URL>bbbb<URL/> </Channel> --- --- </Item> - <Item Type="lmn"> - <Channel id="x"> <Name>xxxx<Name/> <URL>xxxx<URL/> </Channel> - <Channel id="y"> <Name>yyyy<Name/> <URL>yyyy<URL/> </Channel> --- --- </Item> ------ ------ ------ </DOC>
I 've written this Select For XML query
XML, XSLT and XPATH Syntax (Toggle Plain Text)
SELECT ChannelCatID as '@type', ChannelID as 'Channel/@id', ChannelName as 'Channel/Name', RSSFeedURL as 'Channel/URL' FROM ChannelMaster FOR XML PATH('Item'), ROOT('DOC')
It gives me this result
XML, XSLT and XPATH Syntax (Toggle Plain Text)
- <DOC> - <Item Type="xyz"> - <Channel id="a"> <Name>aaaaa<Name/> <URL>aaaaa<URL/> </Channel> </Item> - <Item Type="xyz"> - <Channel id="b"> <Name>bbbb<Name/> <URL>bbbb<URL/> </Channel> </Item> - <Item Type="xyz"> --- </Item> - <Item Type="xyz"> --- </Item> ------ ------ ------ </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.
Hi,
Try adding this to the end of the query:
"group By Item Type"
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.
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.
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- Xml To Query (ColdFusion)
- What exactly is xml? (RSS, Web Services and SOAP)
- XML and hyperlink as one of the data (RSS, Web Services and SOAP)
- PHPMyAdmin -> MSSQL (MySQL)
- Parse XML from ASP!!! (ASP)
- required technical guidence for Struts and XML (Java)
- Amazon Web Services (IT Professionals' Lounge)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Is this valid?
- Next Thread: Looking for ExamXML features in a free application.
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





