Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add attributes dynamically to xmlelement

Dimitri GielisAug 6 2009 — edited Aug 13 2009
Hello,

I'm trying to adding attributes dynamically to an xmlelement. All the attributes are stored in a table.
So what I did is creating a column that holds the attributes in one line e.g.: "sal"="1000" mgr="9827"

So now I've a query like this:
select XMLElement(evalname ename)
from emp;
Which gives me:
<scott></scott>
<james></james>
...

What I want to do is add that attribute to the element so I get
<scott "sal"="1000" mgr="9827"></scott>
...

What I tried is:
select XMLElement(evalname e1.ename, XMLAttributes(e2.my_attributes))
from emp e1, (select ename, '"sal"="100" "mgr"="9876"' my_attributes from emp) e2
where e1.ename = e2.ename
But that results in:
<SCOTT MY_ATTRIBUTES="&quot;sal&quot;=&quot;100&quot; &quot;mgr&quot;=&quot;9876&quot;"></SCOTT>
Anyone an idea how to get arround this? I tried with updateXML but I still have the quotes that get escaped.
Or is there a better way to dynamically add attributes that are stored in a table?

Thanks so much.

Regards,
Dimitri
----------------------------------
http://dgielis.blogspot.com/
http://www.apex-evangelists.com/
This post has been answered by MichaelS on Aug 10 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2009
Added on Aug 6 2009
29 comments
10,875 views