【发布时间】:2023-03-28 22:46:01
【问题描述】:
我有这块 XML 数据,我需要使用 XMLTable 来获取 bulletinWorkl:id 和 bulletinWork/outOfServices/outOfService/document:destinationName。
<?xml version="1.0" encoding="ISO-8859-1"?>
<cern:bulletinWork id="5307cedc-2208-3701-9b9d-e69664b1ef31">
<cern:outOfServices>
<cern:outOfService id="e95d491b-2876-3e08-901f-b0f79be86bfb">
<cern:document destinationName="MonsA" type="S427"></cern:document>
</cern:outOfService>
<cern:outOfService id="fab04992-a33f-3a8c-ad16-29cd54fb93d6">
<cern:document destinationName="MonsB" type="S427"></cern:document>
</cern:outOfService>
</cern:outOfServices>
</cern:bulletinWork>
我正在尝试运行此查询并成功取回 bulletinWork 中的 ID 属性,但 bulletinWork/outOfServices/outOfService/document 中的 destinationName 为空。
select X.Id, X.DestinationName from S1589_XML_Bulletin, XMLTABLE(
'$d/*:bulletinWork'
PASSING XMLTYPE(XML_RAW) as "d"
COLUMNS
Id VARCHAR2(50) PATH '@*:id',
DestinationName VARCHAR2(50) PATH '*:outOfServices/*:outOfService/*:document/*:destinationName'
) AS X
有人看到我在这里做错了吗? 我需要得到:
Id DestinationName
------------------------------------- ------------------
5307cedc-2208-3701-9b9d-e69664b1ef31 MonsA
5307cedc-2208-3701-9b9d-e69664b1ef31 MonsB
【问题讨论】: