在 Oracle PL/SQL 中从 xml 中提取值 [英] Extracting values from xml in Oracle PL/SQL

查看:37
本文介绍了在 Oracle PL/SQL 中从 xml 中提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <ShipmentTrackingResponse xmlns="http://ws.aramex.net/ShippingAPI/v1/">
   <Transaction xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Reference1>001</Reference1>
    <Reference2 i:nil="true"/>
    <Reference3 i:nil="true"/>
    <Reference4 i:nil="true"/>
    <Reference5 i:nil="true"/>
  </Transaction>
  <Notifications xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
  <HasErrors>false</HasErrors>
  <TrackingResults xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"         
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
  <NonExistingWaybills xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"  
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <a:string>XXXXXXXXXX</a:string>
  </NonExistingWaybills>
 </ShipmentTrackingResponse>
</s:Body>

我已使用以下查询来提取值,但是如何提取 NonExistingWaybills?

I have used the following queries to extract values, but how do i extract the NonExistingWaybills?

 SELECT EXTRACTVALUE(l_resp_xml,
                    '//ShipmentTrackingResponse/Transaction/Reference1',
                    'xmlns="http://ws.aramex.net/ShippingAPI/v1/"') 
  INTO l_response_result 
   FROM dual;

  DBMS_OUTPUT.put_line ( 'Result> Reference1=' || l_response_result);

  SELECT EXTRACTVALUE(l_resp_xml,
                     '//ShipmentTrackingResponse/TrackingResults',
                     'xmlns="http://ws.aramex.net/ShippingAPI/v1/"') 
    INTO l_response_result 
    FROM dual;

  DBMS_OUTPUT.put_line ( 'Result> TrackingResults=' || l_response_result);

  SELECT EXTRACTVALUE(l_resp_xml,
                     '//ShipmentTrackingResponse/NonExistingWaybills',
                     'xmlns="http://ws.aramex.net/ShippingAPI/v1/"') 
    INTO l_response_result 
    FROM dual;

  DBMS_OUTPUT.put_line ( 'Result> NonExistingWaybills=' || l_response_result);

最后一个查询没有结果...

The last query gives no result...

推荐答案

返回结果...

SELECT EXTRACTVALUE(l_resp_xml
                  , '//ShipmentTrackingResponse/NonExistingWaybills/node()'
                  , 'xmlns="http://ws.aramex.net/ShippingAPI/v1/"') 
INTO l_response_result
FROM dual;
DBMS_OUTPUT.put_line ( 'Result> NonExistingWaybills=' || l_response_result);

这篇关于在 Oracle PL/SQL 中从 xml 中提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆