I am trying to put together an XML document from several pieces. To get the data, I had several queries whose results were XMLTypes.
I found a function named getNodeFromFragment
in the xmldom package that looked like it could take these XMLTypes and return a DOMNode that contained them, but it doesn't seem to work.
Simple example here:
set serveroutput on;
declare
node xmldom.DOMNode;
node2 xmldom.DOMNode;
doc_node xmldom.DOMNode;
doc xmldom.DOMDocument;
el xmldom.DOMElement;
buf varchar2(1000);
begin
doc := xmldom.newDOMDocument;
el := xmldom.createElement(doc => doc, tagName => 'test');
node := xmldom.makeNode(elem => el);
xmldom.writeToBuffer(node, buf);
dbms_output.put_line('buffer: '||buf);
node := dbms_xmldom.getNodeFromFragment(XMLType('<outer><开发者_运维知识库;inner>soemthing</inner><inner>somethingelse</inner></outer>'));
xmldom.writeToBuffer(node, buf);
dbms_output.put_line('buffer: '||buf);
end;
/
Printing the <test/>
element works fine, but when I try to print the fragment as a node, nothing is output.
Any tips on getNodeFromFragment?
Hi FrustratedWithFormsDesigner,
the following will create a DOMnode object from an XMLType:
node := dbms_xmldom.makenode(dbms_xmldom.newDOMDocument(XMLType(
'<outer><inner>soemthing</inner><inner>somethingelse</inner></outer>')));
This will output:
buffer: <outer>
<inner>soemthing</inner>
<inner>somethingelse</inner>
</outer>
精彩评论