clob to xmltype: converting " to &quote

2.3k Views Asked by At

I am converting clob to xmltype in plsql as below. xml xmltype := xmltype(Input);

Input variables contains the text as below

<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <comment>Hello, this is "james"</comment>
</request>

After the xmltype conversion the text is changed to Hello, this is &quot;james&quot;"

When tried to extract the xml from xmltype I need to extract the text as Hello, this is "james".

2

There are 2 best solutions below

0
On

Xmlcast

select xmlcast(xmltype('<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <comment>Hello, this is "james"</comment>
</request>').extract('/request/comment/text()') as varchar2(100) ) from dual;
0
On

just especify the charset like this: XMLTYPE(Input,NLS_CHARSET_ID('AL32UTF8'))