1

in my procedure I am reading a blob message and after extracting it I am assigning that to a VARCHAR2.

Now since the variable is coming like below (XML format), I would like to read the value of a tag element like host. I have tried using substring function but result is not consistent as Host name string length is keep on changing..

Could you please suggest me some option to have this worked ..?

<fault>
<id>xxxxxxxxxfc709f06870000</id>
<host>***.***.com:2222</host>
<uri>**/**/**.***</uri>
<payload><?xml version="1.0" encoding="UTF-8"?>
kumarb
  • 521
  • 1
  • 7
  • 23
  • I have used this link before to help parse XML and insert the values into tables: [link](https://community.oracle.com/thread/1115266) –  Aug 26 '14 at 12:30
  • Have a look at the SO question : http://stackoverflow.com/questions/12982687/oracle-plsql-how-to-parse-xml-and-insert-into-table – Drumbeg Aug 26 '14 at 12:31

1 Answers1

1

You should use xmltype instead of VARCHAR2.

val xmltype; 
host VARCHAR2;

val := xmltype(varchar2_val); 
host := val.extract('/host/text()').getStringVal()
WadimX
  • 317
  • 1
  • 6