xml version="1.0"
?>
< PEOPLE >
< PERSON PERSONID ="E01" >
< NAME > Tony Blair NAME >
< ADDRESS > 10 Downing Street, London, UK ADDRESS >
< TEL > (061) 98765 TEL >
< FAX > (061) 98768 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
< PERSON PERSONID ="E02" >
< NAME > Bill Clinton NAME >
< ADDRESS > White House, USA ADDRESS >
< TEL > (001) 6400 98765 TEL >
< FAX > (001) 6400 98769 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
< PERSON PERSONID ="E03" >
< NAME > Tom Cruise NAME >
< ADDRESS > 57 Jumbo Street, New York, USA ADDRESS >
< TEL > (001) 4500 67859 TEL >
< FAX > (001) 4500 67895 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
< PERSON PERSONID ="E04" >
< NAME > Linda Goodman NAME >
< ADDRESS > 78 Crax Lane, London, UK ADDRESS >
< TEL > (061) 54 56789 TEL >
< FAX > (061) 54 56772 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
PEOPLE >
< PEOPLE >
< PERSON PERSONID ="E01" >
< NAME > Tony Blair NAME >
< ADDRESS > 10 Downing Street, London, UK ADDRESS >
< TEL > (061) 98765 TEL >
< FAX > (061) 98768 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
< PERSON PERSONID ="E02" >
< NAME > Bill Clinton NAME >
< ADDRESS > White House, USA ADDRESS >
< TEL > (001) 6400 98765 TEL >
< FAX > (001) 6400 98769 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
< PERSON PERSONID ="E03" >
< NAME > Tom Cruise NAME >
< ADDRESS > 57 Jumbo Street, New York, USA ADDRESS >
< TEL > (001) 4500 67859 TEL >
< FAX > (001) 4500 67895 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
< PERSON PERSONID ="E04" >
< NAME > Linda Goodman NAME >
< ADDRESS > 78 Crax Lane, London, UK ADDRESS >
< TEL > (061) 54 56789 TEL >
< FAX > (061) 54 56772 FAX >
< EMAIL > [email protected] EMAIL >
PERSON >
PEOPLE >
个人学习总结 如果输入的存储地址,则 用 XXX in varchar2,
在xmlparser.parse(xmlPar,XXX);
CREATE OR REPLACE
PROCEDURE P_AddPartPopedom(partPopedom_xml in clob)
as
------------------=================该存储过程负责存储角色权限================---------------------
--//XML解析器
xmlPar XMLPARSER.parser := XMLPARSER.NEWPARSER;
--//DOM文档对象
doc xmldom.DOMDocument;
len Integer;
personNodes xmldom.DOMNodeList;
chilNodes xmldom.DOMNodeList;
tempNode xmldom.DOMNode;
tempArrMap xmldom.DOMNamedNodeMap;
--================================
--以下变量用于获取XML节点的值
partNum varchar2(50); --角色编号
menuNum varchar2(50); --菜单编号
operateNum varchar2(50); --操作编号
tmp Integer;
--================
BEGIN
xmlPar := xmlparser.newParser;
xmlparser.parseClob(xmlPar,partPopedom_xml);
doc := xmlparser.getDocument(xmlPar);
-- 释放解析器实例
xmlparser.freeParser(xmlPar);
personNodes := xmldom.getElementsByTagName_r(doc, 'PARTPOPEDOM');
len := xmldom.getLength( personNodes );
--遍历所有PERSON元素
FOR i in 0..len-1
LOOP
--获取第i个
tempNode := xmldom.item(personNodes, i);
--所有属性
tempArrMap := xmldom.getAttributes(tempNode);
--获取PERSONID的值
--pid := xmldom.getNodeValue(xmldom.getNamedItem(tempArrMap,'POPEDOM'));
--获取子元素的值
chilNodes := xmldom.getChildNodes(tempNode);
tmp := xmldom.GETLENGTH(chilNodes);
partNum := xmldom.getNodeValue(xmldom.getFirstChild(xmldom.item(chilNodes, 0)));
menuNum := xmldom.getNodeValue(xmldom.getFirstChild(xmldom.item(chilNodes, 1)));
operateNum := xmldom.getNodeValue(xmldom.getFirstChild(xmldom.item(chilNodes, 2)));
--插入数据
INSERT INTO SD_SYS_PARTPOPEDOM VALUES (SEQ_SDSYSPARTPOPEDOM.nextval, partNum, menuNum, operateNum);
COMMIT;
END LOOP;
-- 释放文档对象
xmldom.freeDocument(doc);
EXCEPTION
WHEN OTHERS THEN
DBMS_output.PUT_LINE(SQLERRM);
END P_AddPartPopedom;