How can I convert table data to XML?
There is a table:
------------- ALLTAGS ------------- TAGID | COUNT ------------- 1 | 2 2 | 5 3 | 4 ------------- You need to get the following XML:
<ALLSCOPES> <ResultTag> <Tag_ID>1</Tag_ID> <Tag_Count>2</Tag_Count> </ResultTag> <ResultTag> <Tag_ID>2</Tag_ID> <Tag_Count>5</Tag_Count> </ResultTag> <ResultTag> <Tag_ID>3</Tag_ID> <Tag_Count>4</Tag_Count> </ResultTag> </ALLSCOPES> I try to do this:
SELECT (XMLElement("ALLSCOPES", XMLElement("ResultTag", XMLElement("Tag_ID", t.TAG_ID), XMLElement("Tag_Count", t.TAGCOUNT))) ).GetStringVal() as ALLSCOPES FROM ALLTAGS t; but I get 3 entries like:
<ALLSCOPES> <ResultTag> <Tag_ID>1</Tag_ID> <Tag_Count>2</Tag_Count> </ResultTag> </ALLSCOPES> <ALLSCOPES> <ResultTag> <Tag_ID>2</Tag_ID> <Tag_Count>5</Tag_Count> </ResultTag> </ALLSCOPES> etc.
How to solve my problem?