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

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐