Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have created 1 XML node using oracle. i need the output some different way, means one of the node i don't want to close as node name only</> code is like below.

CREATE or replace FUNCTION GetEmpName
(

    NAME VARCHAR
)

RETURN varchar2

IS RtKeys varchar2(2000);
BEGIN
          SELECT XMLElement("TableKeys",
                     XMLAGG(XMLElement("rt",  XMLAttributes(e.ENAME||' 'AS ENAME,e.EMPNO AS EmNo),
                            XMLElement("rb", XMLAttributes(e.HIREDATE||' 'AS HIREDATE,e.JOB||' 'AS JOB))))
                   ).getStringVal()
  INTO RtKeys
  FROM emp e  inner join EMPDep ed
  on e.DEPTNO = ed.DEPTNO where e.ename = NAME order by e.JOB;
  RETURN RtKeys;

END;


output i am getting as:

<TableKeys><rt ENAME="ADAMS " EMNO="7876"><rb HIREDATE="12-JAN-83 " JOB="CLERK
"></rb></rt></TableKeys>


but i need the output as below:

<tablekeys><rb HIREDATE="12-JAN-83 " JOB="CLERK
"></>



my expected output: <rb ........></> only need to use </>


please look into the code and tell me how to do.

What I have tried:

i have tried as passing.

XMLElement("rb", XMLAttributes(e.HIREDATE||' 'AS HIREDATE,e.JOB||' 'AS "JOB"


but not working.
Posted
Updated 10-Dec-18 3:59am
v6
Comments
Richard Deeming 11-Dec-18 8:48am    
If you want to generate something that's not valid XML, then you can't use XML to generate it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900