运行Oracle 10g,sqldeveloper 1.5.5
我想在sqldeveloper的输出或结果窗口中以字符串形式查看DBMS_XMLDOM.DOMDocument的内容.或者其他一些调试这个东西的简单方法……
谢谢,P
解决方法
DBMS_XMLDOM.WRITETOBUFFER Writes the contents of the node to a buffer. DBMS_XMLDOM.WRITETOCLOB Writes the contents of the node to a CLOB. DBMS_XMLDOM.WRITETOFILE Writes the contents of the node to a file.
我有PL / sql代码,它使用DIRECTORY将它连接到文件系统:
dbms_xmldom.writeToFile(dbms_xmldom.newDOMDocument( xmldoc),'DATAPUMPDIR/myfile.xml') ;
我使用dbms_xmldom.writetoclob创建了一个函数
create or replace function xml2clob (xmldoc XMLType) return CLOB is clobdoc CLOB := ' '; begin dbms_xmldom.writeToClob(dbms_xmldom.newDOMDocument( xmldoc),clobdoc) ; return clobdoc; end; /
查询:
SELECT xml2clob(Sys_Xmlagg( Xmlelement(Name "dummy",dummy ),Xmlformat('dual'))) FROM dual;
输出:
<?xml version="1.0"?> <dual> <dummy>X</dummy> </dual>
您可以尝试使用这样的函数:
create or replace function dom2clob (domdoc DBMS_XMLDOM.DOMDocument) return CLOB is clobdoc CLOB := ' '; begin dbms_xmldom.writeToClob(domdoc,clobdoc) ; return clobdoc; end; /