awking00
asked on
XMLElement function not working as expected
I have a table called players with the following attributes and values:
PLAYER_ID PLAYER_NAME
---------- ------------
1 Smith
2 Jones
3 Wilson
When I issued this query,
select XMLElement("Player",
XMLElement("PlayerID",play er_id),
XMLElement("PlayerName",pl ayer_name) )
from players;
I expected to see results something like this
<Player>
<PlayerID>1</PlayerID>
<PlayerName>Smith</PlayerN ame>
</Player>
<Player>
<PlayerID>2</PlayerID>
<PlayerName>Jones</PlayerN ame>
</Player>
<Player>
<PlayerID>3</PlayerID>
<PlayerName>Wilson</Player Name>
</Player>
but what actually returned was
XMLTYPE()
XMLTYPE()
XMLTYPE()
Is there something I need to do to get this to work?
PLAYER_ID PLAYER_NAME
---------- ------------
1 Smith
2 Jones
3 Wilson
When I issued this query,
select XMLElement("Player",
XMLElement("PlayerID",play
XMLElement("PlayerName",pl
from players;
I expected to see results something like this
<Player>
<PlayerID>1</PlayerID>
<PlayerName>Smith</PlayerN
</Player>
<Player>
<PlayerID>2</PlayerID>
<PlayerName>Jones</PlayerN
</Player>
<Player>
<PlayerID>3</PlayerID>
<PlayerName>Wilson</Player
</Player>
but what actually returned was
XMLTYPE()
XMLTYPE()
XMLTYPE()
Is there something I need to do to get this to work?
btw, off topic, please post your code about the iso weeks, I never did figure out what you were doing with the function based index that pertained to that question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And if you wanted all of the rows to be inside a single xml doc,
then use xmlagg to aggregate them.
and, that too returns an xmltype, so use getclobval on the xmlagg's returned value to see the combined xml
select XMLAGG(XMLElement("Player" ,
XMLElement("PlayerID",play er_id),
XMLElement("PlayerName",pl ayer_name) )
).getclobval()
from players;
then use xmlagg to aggregate them.
and, that too returns an xmltype, so use getclobval on the xmlagg's returned value to see the combined xml
select XMLAGG(XMLElement("Player"
XMLElement("PlayerID",play
XMLElement("PlayerName",pl
).getclobval()
from players;
each type contains the player node you're looking for