【发布时间】:2017-05-24 23:14:19
【问题描述】:
给出的是“XYZ”表中“my_xml”列的值
<?xml version="1.0" encoding="UTF-8"?>
<India>
<city>
<string>ADI</string>
<string>Ahmedabad</string>
</city>
<city>
<string>GNR</string>
<string>Gandhinagar</string>
</city>
<city>
<string>PUN</string>
<string>Pune</string>
</city>
<city>
<string>RJT</string>
<string>Rajkot</string>
</city>
</India>
我正在尝试提取第二个 string 节点的值,其中第一个 string 节点值为 ADI
输出应仅为“艾哈迈达巴德”
尝试失败:
select t.my_xml.extract('/India/city/string[2]/text()').getStringVal() from XYZ t where t.my_xml.existsNode('/India/city[string[1] = "ADI"]') = 1;
上述查询的输出是AhmedabadGandhinagarPuneRajkot
预期输出:Ahmedabad
这里如何提取string节点的特定节点值?
【问题讨论】:
标签: sql xml oracle extract oracle-xml-db