| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Help extracting XML from db gives extra element/tag
Thank you for taking the time to read my post. I am new to oracle and
put in a high pressure situation where I need to extract XML from a
relational DB. I was able to get all the info I need in the right
format, with one exception an extra tag! How do I get rid of the
XMLTYPE tag that is created around the client tag (which is generated
from the XMLSEQUENCE function).
Thank you in advance, the code and the output are posted below.
The select statement is as follows:
SELECT
(
XMLELEMENT
(
"items"
,XMLCONCAT
(
XMLSEQUENCE
(
CURSOR
(
SELECT
changedFunds.cusip as "cusip"
,changedFunds.tradingsymbol as "trading-symbol"
,changedFunds.registered as "registered"
,XMLSEQUENCE
(
CURSOR
(
/*clients from legacy system 1 */
SELECT
freq.clientId as "client-id"
,freq.frequency as "frequency"
FROM
FactSheetFrequency freq NATURAL JOIN Fund_Lineup
clientFunds
WHERE
freq.clientId = 1
AND clientFunds.cusip = changedFunds.cusip
UNION
/*clients from legacy system 2 */
SELECT
freq.clientId as "client-id"
,freq.frequency as "frequency"
FROM
FactSheetFrequency freq NATURAL JOIN
Fund_Lineup_Lincoln clientFunds
WHERE
freq.clientId = 2
AND changedFunds.cusip = clientFunds.cusip
)
,XMLFORMAT('client')
) as "clients"
FROM
factsheetqueue changedFunds
)
,XMLFORMAT('item')
)
)
res
FROM
dual
And generates the foloowing XML
<items>
<item> <cusip>1</cusip> <trading-symbol>funda</trading-symbol> <registered>1</registered> <clients> <XMLTYPE> <client> <client-id>1</client-id> <frequency>weekly</frequency> </client> </XMLTYPE> <XMLTYPE> <client> <client-id>2</client-id> <frequency>quarterly</frequency> </client> </XMLTYPE> </clients> </item> <item> <cusip>2</cusip> <trading-symbol>fundb</trading-symbol> <registered>0</registered> <clients> <XMLTYPE> <client> <client-id>2</client-id> <frequency>quarterly</frequency> </client> </XMLTYPE> </clients> </item> <item> <cusip>3</cusip> <trading-symbol>fundc</trading-symbol> <registered>0</registered> <clients> <XMLTYPE> <client> <client-id>1</client-id> <frequency>weekly</frequency> </client> </XMLTYPE> </clients> </item>
![]() |
![]() |