1
<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>

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...

Nick Krasnov
  • 26,886
  • 6
  • 61
  • 78
Novice
  • 557
  • 1
  • 7
  • 16
  • 2
    I tried this and it returned the XXXX value SELECT EXTRACTVALUE(xdata, '//ShipmentTrackingResponse/NonExistingWaybills/*', 'xmlns="http://ws.aramex.net/ShippingAPI/v1/"') from x – OldProgrammer Jul 29 '13 at 18:24
  • Yes thanks a lot..I solved it see below – Novice Jul 30 '13 at 09:34

2 Answers2

2

It returned results...

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);
APC
  • 144,005
  • 19
  • 170
  • 281
Novice
  • 557
  • 1
  • 7
  • 16
1

This will return the same result, but without select. I guess this is what you were looking for:

l_response_result := l_resp_xml.extract(
    '//ShipmentTrackingResponse/NonExistingWaybills/node()'
).getstringval();
Gerrit Griebel
  • 405
  • 3
  • 10
  • 2
    **From review queue:** May I request you to please add some more context around your answer. Code-only answers are difficult to understand. It will help the asker and future readers both if you can add more information in your post. See also [Explaining entirely code-based answers](https://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers). – help-info.de Jul 29 '17 at 15:40
  • Just found [here](https://docs.oracle.com/database/121/ADXDB/xdb_xquery.htm#ADXDB5097) this note: "Prior to Oracle Database 11g Release 2, some users employed Oracle SQL functions extract and extractValue to do some of what can be done better using SQL/XML functions XMLQuery and XMLCast. SQL functions extract and extractValue are deprecated in Oracle Database 11g Release 2." – Gerrit Griebel Aug 02 '17 at 13:36
  • Annoyingly, extract.getstringval() behaviour is subtly different from extractvalue in that if the node does not exist, extract returns "ORA-30625: method dispatch on NULL SELF argument is disallowed", whereas extractvalue returns null – Pancho Jan 31 '18 at 20:36