Home » Developer & Programmer » JDeveloper, Java & XML » Parsing XML (Oracle Database 11g Enterprise Edition Release 11.2.0.4.0)
Parsing XML [message #642067] Tue, 01 September 2015 15:38 Go to next message
Duane
Messages: 452
Registered: December 2002
Senior Member
Any idea on how to get the value of "ns:return"? The value returned should be "0066012c76be4260b4b3f466b20e8be0"


<?xml version='1.0' encoding='utf-8'?>
  <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soapenvelope">
    <soapenv:Body>
      <ns:initializeResponse xmlns:ns="http://context.ws.blackboard">
         <ns:return>0066012c76be4260b4b3f466b20e8be0</ns:return>
      </ns:initializeResponse>
    </soapenv:Body>
</soapenv:Envelope>





Been trying this:

resp_extract    xmltype;

resp_extract := resp.extract('/soapenv:Envelope/soapenv:Body/child::node()', 'xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"');


I think if someone could show me how it's done then I'll understand what values to plug into where.
Re: Parsing XML [message #642108 is a reply to message #642067] Wed, 02 September 2015 14:33 Go to previous messageGo to next message
Barbara Boehmer
Messages: 8751
Registered: November 2002
Location: California, USA
Senior Member
This may not be the most efficient method. I was just trying to come as close as I could to the method it looks like you are trying to use and get the desired result.

SCOTT@orcl> declare
  2    resp	       xmltype;
  3    resp_extract    xmltype;
  4  begin
  5    resp := xmltype
  6  	 ('<?xml version=''1.0'' encoding=''utf-8''?>
  7  	     <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soapenvelope">
  8  	       <soapenv:Body>
  9  		 <ns:initializeResponse xmlns:ns="http://context.ws.blackboard">
 10  		   <ns:return>0066012c76be4260b4b3f466b20e8be0</ns:return>
 11  		 </ns:initializeResponse>
 12  	       </soapenv:Body>
 13  	   </soapenv:Envelope>');
 14    resp_extract := resp.extract
 15  	 ('/soapenv:Envelope/soapenv:Body/child::node()/ns:return/child::node()',
 16  	  'xmlns:soapenv="http://www.w3.org/2003/05/soapenvelope"
 17  	   xmlns:ns="http://context.ws.blackboard"');
 18    dbms_output.put_line (resp_extract.getclobval);
 19  end;
 20  /
0066012c76be4260b4b3f466b20e8be0

PL/SQL procedure successfully completed.

[Updated on: Wed, 02 September 2015 14:39]

Report message to a moderator

Re: Parsing XML [message #642109 is a reply to message #642108] Wed, 02 September 2015 14:39 Go to previous messageGo to next message
Duane
Messages: 452
Registered: December 2002
Senior Member
That works. Thanks.

By the way, do you know how to get a time stamp in the following format?

2015-09-08T09:46:48.484Z


<wsu:Created>2015-09-08T09:46:48.484Z</wsu:Created>
<wsu:Expires>2015-09-08T09:47:48.484Z</wsu:Expires>



The dateTime data type is used to specify a date and a time.

The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:

YYYY indicates the year
MM indicates the month
DD indicates the day
T indicates the start of the required time section
hh indicates the hour
mm indicates the minute
ss indicates the second

[Updated on: Wed, 02 September 2015 14:39]

Report message to a moderator

Re: Parsing XML [message #642111 is a reply to message #642109] Wed, 02 September 2015 15:31 Go to previous messageGo to next message
Michel Cadot
Messages: 65208
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Is this what you want?
SQL> select to_timestamp('2015-09-08T09:46:48.484Z','YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') d from dual;
D
---------------------------------------------------------------------------
08/09/2015 09:46:48.484
Re: Parsing XML [message #642112 is a reply to message #642111] Wed, 02 September 2015 15:34 Go to previous messageGo to next message
Michel Cadot
Messages: 65208
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Or is this the opposite?
SQL> select to_char(systimestamp,'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') d from dual;
D
------------------------------
2015-09-02T22:33:32.593Z

Re: Parsing XML [message #642113 is a reply to message #642112] Wed, 02 September 2015 15:42 Go to previous messageGo to next message
Duane
Messages: 452
Registered: December 2002
Senior Member
Last one is what I need but it would appear I need GMT.

Something like this:

replace(TO_CHAR (CAST (systimestamp AT TIME ZONE 'GMT' AS TIMESTAMP ( 3 )), 'rrrr-mm-dd hh24:mi:ss.ff'),' ','T')||'Z'

I'm sure you can come up with something better.
Re: Parsing XML [message #642116 is a reply to message #642113] Wed, 02 September 2015 17:04 Go to previous messageGo to next message
Barbara Boehmer
Messages: 8751
Registered: November 2002
Location: California, USA
Senior Member
SCOTT@orcl> select TO_CHAR
  2  	      (CAST (systimestamp AT TIME ZONE 'GMT' AS TIMESTAMP ( 3 )),
  3  	       'rrrr-mm-dd"T"hh24:mi:ss.ff"Z"')
  4  from   dual
  5  /

TO_CHAR(CAST(SYSTIMESTAMPATTIM
------------------------------
2015-09-02T22:02:12.559Z
Re: Parsing XML [message #642121 is a reply to message #642113] Thu, 03 September 2015 00:55 Go to previous messageGo to next message
Michel Cadot
Messages: 65208
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
I'm sure you can come up with something better.


Yes, I showed you.

Re: Parsing XML [message #642141 is a reply to message #642121] Thu, 03 September 2015 09:26 Go to previous message
Duane
Messages: 452
Registered: December 2002
Senior Member
Yes, and thank you. I'm already using your version.
Previous Topic: JDeveloper
Next Topic: 32-bit Java Application running in a 64-bit OS
Goto Forum:
  


Current Time: Sat Nov 25 03:13:31 CST 2017

Total time taken to generate the page: 0.06976 seconds