日期:2014-05-17  浏览次数:21159 次

新手使用ORACLE中XMLDOM的问题
我第一次用XMLDOM,写了个小例如下:
SQL code

create or replace procedure aaaproc
is
  document    xmldom.DOMDocument;
  domElement  xmldom.DOMElement;
  tempnode    xmldom.DOMNode;
  RR varchar2(4000);
  xmldoc  clob;
begin
  document := xmldom.newDOMDocument;
  domElement := xmldom.createElement(document,'coco');
  xmldom.setAttribute(domElement,'uname','huangj');
  --xmldom.setNodeValue(domElement,'helloworld');
  tempnode := xmldom.appendChild(xmldom.makeNode(document),xmldom.makeNode(domElement));
  xmldom.setVersion(document, '1.0');
  xmldom.setCharset(document, 'GBK');
  xmldoc := ' ';
  xmldom.writeToClob(document, xmldoc);
  xmldom.freeDocument(document);
  RR := xmldoc;
  dbms_output.put_line(RR);
end;


输出结果为:
<?xml version = '1.0'?>
<coco uname="huangj"/>

而后我想在<coco uname="huangj"></coco>标记之间添加点内容,就加了句
xmldom.setNodeValue(domElement,'helloworld');

重新创建时出错
PROCEDURE DLYX.AAAPROC 编译错误
错误:PLS-00306: 调用 'SETNODEVALUE' 时参数个数或类型错误
行:15
文本:xmldom.setNodeValue(domElement,'helloworld');
错误:PL/SQL: Statement ignored
行:15
文本:xmldom.setNodeValue(domElement,'helloworld');


这样的话这句要怎么写?那位要是有XMLDOM帮助文档的话方便就给我一份,谢谢!!!

------解决方案--------------------
MS不能直接设置,你可以试试这样:

text xmldom.DOMText;

text = xmldom.createTextNode(document,'helloworld');
tempnode := xmldom.appendChild(domElement,xmldom.makeNode(text)); 

XMLDOM帮助文档我也找了很久都未果,痛苦。。。