I am trying to generating below format xml using function:
XML
<?xml version="1.0" encoding="UTF-8"?>
<OUTPUT xmlns:xsi="http://www.w3.org">
....
Function:
FUNCTION f_get_details(
p_employee_id NUMBER)
RETURN XMLTYPE
IS
v_xmltype xmltype;
--
main_node xmldom.DOMnode;
ROOT_NODE XMLDOM.DOMNODE;
root_elmt xmldom.domelement;
l_con_node dbms_xmldom.DOMnode;
--
BEGIN
l_domdoc := xmldom.newDomDocument;
--
main_node := xmldom.makenode(l_domdoc);
root_elmt := xmldom.createelement(l_domdoc, 'OUTPUT');
--
xmldom.setattribute(elem => root_elmt, name=> 'xmlns:xsi', newvalue=>'http://www.w3.org');
--
v_xmltype := dbms_xmldom.getXMLType(l_domdoc);
dbms_xmldom.freeDocument(l_domdoc);
return v_xmltype;
END f_get_details;
function is generating xml in correct format but I am not able to mention namespace of output node. How I should fix it?
I have given namespace in this line of code:
xmldom.setattribute(elem => root_elmt, name=> 'xmlns:xsi', newvalue=>'http://www.w3.org');