Oracle解析XML数据
今天偶然发现Oracle能用SQL解析XML文件,所以好奇之下查了些资料。
把例子列出来有兴趣的同仁可以看看
select * from xmltable(
'$B/Person/Student' passing ---这里指定根节点
xmltype(
'<?xml version="1.0" encoding="gb2312" ?>
<Person>
<Student>
<name>孙悟空</name>
<sex>男</sex>
<age>1234</age>
</Student>
<Student>
<name>猪八戒</name>
<sex>男</sex>
<age>1345</age>
</Student>
<Student>
<name>蜘蛛精</name>
<sex>女</sex>
<age>231</age>
</Student>
</Person>
') as B
columns ---指定列名称
name varchar2(32) path '/Student/name',
sex varchar2(4) path '/Student/sex',
age number(10) path '/Student/age'
);