pl/sql:将 xmltype 转换为节点
我正在尝试将多个部分组合成一个 XML 文档。为了获取数据,我进行了几次查询,其结果都是 XMLType。
我在 xmldom 包中发现了一个名为 getNodeFromFragment
的函数,它看起来可以获取这些 XMLType 并返回包含它们的 DOMNode,但它似乎不起作用。
这里是一个简单的例子:
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;
/
打印
元素工作正常,但是当我尝试将片段打印为节点时,没有任何输出。
关于 getNodeFromFragment 有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您好,FrustratedWithFormsDesigner,
下面将从 XMLType 创建一个 DOMnode 对象:
这将输出:
Hi FrustratedWithFormsDesigner,
the following will create a DOMnode object from an XMLType:
This will output: