Five pre-defined entities in the XML document

Source: Internet
Author: User

Problem description:

When outputting XML files out of PL/SQL, You need to convert the five predefined entities of XML:

Below are five predefined entities in the XML document:

& Lt; < Yu no.
& Gt; > Yu no.
& Amp; & And
& Apos; ' Single quotes
& Quot; " Double quotation marks

 

Solution:

A procedure is usually used in PL/SQL for conversion:

 

 

-- The five objects predefined in XML are in the XML output file, the following characters must use the Escape Character of XML <br/>/* = ==============================< br/> * function/procedure <br/> * transform_xml_entity <br/> * description: <br/> * convert the predefined XML entity in the output character to the Escape Character of XML. <br/> * argument: <br/> * p_value: output XML content <br/> * return: <br/> * N/A <br/> * history: <br/> * 1.00 17/07/2010 cxy <br/> * ================ =====================================*/<br/> function transform_xml_entity (p_value in varchar2) return varchar2 is <br/> l_value varchar2 (2000); <br/> begin <br/> l_value: = p_value; <br/> l_value: = Replace (l_value, '<', CHR (38) | 'lt;'); <br/> l_value: = Replace (l_value, '>', CHR (38) | 'gt; '); <br/> l_value: = Replace (l_value,' & ', CHR (38) |' amp; '); <br/> l_value: = Replace (l_value, ''', CHR (38) | 'apos; '); <br/> l_value: = Replace (l_value ,'"', CHR (38) | 'quot; '); </P> <p> return l_value; <br/> end transform_xml_entity;

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.