From: plissken on
Can anyone help me with this problem. I'm using Oracle 9i and SQL
Developer 1.0.0.15.27.

Here is some test code.

CREATE OR REPLACE PROCEDURE TEST AS
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
root_text xmldom.DOMText;
root_name xmldom.DOMNode;

v_cResult CLOB;

BEGIN

doc := xmldom.newDOMDocument;

xmldom.setversion(doc, '1.0');
xmldom.setCharset(doc,'UTF-8');

main_node := xmldom.makeNode(doc);
root_elmt := xmldom.createElement(doc, 'EMP');
root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
root_text := xmldom.createtextnode(doc, 'where is the header?');
root_name := xmldom.appendChild(root_node, xmldom.makeNode(root_text));

dbms_xmldom.WRITETOCLOB(doc, v_cResult);
dbms_output.PUT_LINE(substr(v_cResult,1,255));
xmldom.freeDocument(doc);
END;

The output is

<EMP>where is the header?</EMP>

I really need

<?xml version="1.0" encoding="UTF-8" ?>
<EMP>where is the header?</EMP>

Thanks in advance.

Plissken.