Skip to Content
0
Former Member
Apr 12, 2006 at 12:47 PM

XML conversion special characters.

90 Views

Hi,

I need to convert an XML containing special characters like & ' < to the XML codification (&amp,&apos, ..).

I'm having an XML like this :

<?xml version=''1.0'' encoding=''UTF-8''?>

<ROOT xmlns:sql=''urn:schemas-microsoft-com:xml-sql'' >

<sql:query>

select * from table where field = '1241&'

</sql:query>

</ROOT>

I tried to use the class cl_xml_document.

here is part of the code :

CALL METHOD lo_mxml->parse_string

EXPORTING

stream = xmlbody.

CALL METHOD lo_mxml->render_2_string

EXPORTING

PRETTY_PRINT = 'X'

IMPORTING

RETCODE = lv_Retcode

STREAM = lv_String

SIZE = lv_size.

CALL METHOD lo_mxml->display.

the result is :

<?xml version="1.0" encoding="iso-8859-1"?>

<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">

<sql:query>

SELECT * FROM table where field = &apos;1

</sql:query>

</ROOT>

the rendering stops after having replaced the first special characters. any idea ? or another way for doing that ?

any help will be appreciated.

thanks,

regards,

Abdelaltif