Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XMLTable不从XML中的子级获取数据_Xml_Oracle_Plsql_Xmltable - Fatal编程技术网

XMLTable不从XML中的子级获取数据

XMLTable不从XML中的子级获取数据,xml,oracle,plsql,xmltable,Xml,Oracle,Plsql,Xmltable,我有这段XML数据,需要使用XMLTable获取其bulletinWork:id和bulletinWork/outOfService/outOfService/document:destinationName 有人知道我做错了什么吗? 我需要得到: Id DestinationName ------------------------------------- ------------------ 5307cedc

我有这段XML数据,需要使用XMLTable获取其bulletinWork:id和bulletinWork/outOfService/outOfService/document:destinationName

有人知道我做错了什么吗? 我需要得到:

Id                                       DestinationName
-------------------------------------    ------------------
5307cedc-2208-3701-9b9d-e69664b1ef31     MonsA
5307cedc-2208-3701-9b9d-e69664b1ef31     MonsB
对于不固定的属性,不必使用名称空间。它们的名称空间定义为父元素

在示例xml中有多个cern:outOfService,这就是我使用字符串连接和不同值的原因

更新:

它更长,但对我来说更清晰。两个xml表的联接

    select * from xmltable('*:bulletinWork' passing xmltype('<cern:bulletinWork id="5307cedc-2208-3701-9b9d-e69664b1ef31" xmlns:cern="aaa">
      <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>')
    COLUMNS
            Id                  VARCHAR2(50) PATH   '@id',
            outOfServices       xmltype   path '*:outOfServices'  
    ) t1 
    ,xmltable('*:outOfServices/*:outOfService' passing t1.outOfServices 
    COLUMNS DestinationName     VARCHAR2(50) PATH   '*:document/@destinationName')
2从子节点访问父节点

select * from xmltable('*:bulletinWork/*:outOfServices/*:outOfService' passing xmltype('<cern:bulletinWork id="5307cedc-2208-3701-9b9d-e69664b1ef31" xmlns:cern="aaa">
  <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>')
COLUMNS
        Id                  VARCHAR2(50) PATH   './../../@id', 
        DestinationName     VARCHAR2(50) PATH   '*:document/@destinationName'
)
对于不固定的属性,不必使用名称空间。它们的名称空间定义为父元素

在示例xml中有多个cern:outOfService,这就是我使用字符串连接和不同值的原因

更新:

它更长,但对我来说更清晰。两个xml表的联接

    select * from xmltable('*:bulletinWork' passing xmltype('<cern:bulletinWork id="5307cedc-2208-3701-9b9d-e69664b1ef31" xmlns:cern="aaa">
      <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>')
    COLUMNS
            Id                  VARCHAR2(50) PATH   '@id',
            outOfServices       xmltype   path '*:outOfServices'  
    ) t1 
    ,xmltable('*:outOfServices/*:outOfService' passing t1.outOfServices 
    COLUMNS DestinationName     VARCHAR2(50) PATH   '*:document/@destinationName')
2从子节点访问父节点

select * from xmltable('*:bulletinWork/*:outOfServices/*:outOfService' passing xmltype('<cern:bulletinWork id="5307cedc-2208-3701-9b9d-e69664b1ef31" xmlns:cern="aaa">
  <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>')
COLUMNS
        Id                  VARCHAR2(50) PATH   './../../@id', 
        DestinationName     VARCHAR2(50) PATH   '*:document/@destinationName'
)

你的解决方案很好用,谢谢。我只是稍微调整了一下这个问题,因为为了验证的目的,我可能需要在之后分别使用所有DestinationName。有没有办法让我同时拥有他们而不是加入他们?你的解决方案很好,谢谢。我只是稍微调整了一下这个问题,因为为了验证的目的,我可能需要在之后分别使用所有DestinationName。有没有办法让他们两个都来,而不是加入他们?
select * from xmltable('*:bulletinWork/*:outOfServices/*:outOfService' passing xmltype('<cern:bulletinWork id="5307cedc-2208-3701-9b9d-e69664b1ef31" xmlns:cern="aaa">
  <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>')
COLUMNS
        Id                  VARCHAR2(50) PATH   './../../@id', 
        DestinationName     VARCHAR2(50) PATH   '*:document/@destinationName'
)