首页 > 代码库 > PLSQL XML特殊字符转换

PLSQL XML特殊字符转换

---特殊字符转换

  function process_xml(old_xml in varchar2) return varchar2 as

    new_xml varchar2(1000);

  begin

    select replace(old_xml, ‘<‘, ‘&lt;‘) into new_xml from dual;

    select replace(new_xml, ‘>‘, ‘&gt;‘) into new_xml from dual;

    select replace(new_xml, ‘&‘, ‘&amp;‘) into new_xml from dual;

    select replace(new_xml, ‘‘‘‘, ‘&apos;‘) into new_xml from dual;

    select replace(new_xml, ‘"‘, ‘&quot;‘) into new_xml from dual;

  

    SELECT regexp_replace(new_xml, ‘^(\W)*|(\W)*$‘, ‘‘)

      INTO new_xml

      FROM dual;

  

    return new_xml;

  exception

    when others then

      return ‘ERROR!‘;

  end process_xml;


PLSQL XML特殊字符转换