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"?>
<DATA>
<name>Munising Falls</name>
<county>Alger</county>
<state>MI</state>
<url>
[url]http://michiganwaterfalls.com/munising_falls/munising_falls.html[/url]
</url>
</DATA>'));
INSERT INTO xmlcontent VALUES (1, XMLType.CreateXML(
'<?xml version="1.0"?>
<DATA>
<name>snowhill.c</name>
<county>china</county>
<state>hubei</state>
<url>
http://www.blog.com/snowhill
</url>
</DATA>'));
--检查节点是否存在
select keyvalue From xmlcontent where existsNode(xmlvalue,'/DATA/url')>0
--提取节点内容
select extractValue(xmlvalue, '/DATA/name') from xmlcontent