oracle 9i 以后是对xml做了支持的,先建立xmltype类型的字段
--创建xmltype 类型的表
create table xmlcontent (keyvalue varchar2(10) primary key,
xmlvalue xmltype);
--建立目录,如果不读文件可以不用
grant create any directory to snowhill;
select * from dba_directories ;
create directory xmldir as 'd:\oracle\xml';
--使用xmltype的静态方法createxml插入xml数据
INSERT INTO xmlcontent VALUES (2, XMLType.CreateXML(
'<?xml version="1.0"?>
Munising Falls
Alger
MI
[url]http://michiganwaterfalls.com/munising_falls/munising_falls.html[/url]
'));
INSERT INTO xmlcontent VALUES (1, XMLType.CreateXML(
'<?xml version="1.0"?>
snowhill.c
china
hubei
http://www.blog.com/snowhill
'));
--检查节点是否存在
select keyvalue From xmlcontent where existsNode(xmlvalue,'/DATA/url')>0
--提取节点内容
select extractValue(xmlvalue, '/DATA/name') from xmlcontent
posted on 2013-09-02 17:59 snowhill 阅读(135) 评论(0) 编辑 收藏 引用 所属分类: 数据库-oracle