‎2008 May 29 7:38 PM
Hi,
I want to convert XML file into XString.
The XML file is in itab and this itab is converted into a String using CONVERT_TABLE_TO_STRING funciotn module. This XML file into String conversion is done correctly.
When I tried String to XString conversion using TREX_TEXT_TO_XSTRING, the xstring variable results with many special characters (in some other langauage).
Or, when I tried converting itab to xstring using itab_to_xstring, xstring results with many extra characters.
Encoding style in xml is UTF-8.
Please let me know the correct way to convert xml to xstring.
Thanks,
Uma
‎2008 May 29 7:40 PM
Hello,
Try this fm:
*Convert STRING to XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = iv_content
* MIMETYPE = ' '
* ENCODING =
IMPORTING
buffer = ev_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
ev_subrc = 4.
ENDIF.
Regards.
‎2008 May 29 7:40 PM
Hello,
Try this fm:
*Convert STRING to XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = iv_content
* MIMETYPE = ' '
* ENCODING =
IMPORTING
buffer = ev_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
ev_subrc = 4.
ENDIF.
Regards.
‎2008 May 29 7:46 PM
Hi David,
Thanks for your reply.
I tried this function module also. XString return with special characters.
Thanks,
Uma
‎2008 May 29 7:59 PM
Check out this [/people/thomas.jung3/blog/2004/08/09/bsp-download-to-excel-in-unicode-format]
This weblog talks about excel but applies to your case as well.
Regards.
‎2008 May 29 8:45 PM
Thanks David.
I changed my code as below
data:
bdata type xstring,
G_STR type STRING,
APP_TYPE type char30.
clear bdata.
APP_TYPE = 'text/unicode; charset=utf-16le'.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = G_STR
MIMETYPE = APP_TYPE
* ENCODING =
IMPORTING
BUFFER = bdata
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.But the xstring bdata results with "square box" character after each character.
Thanks,
Uma
‎2008 May 31 9:14 AM
are you viewing the xstring in debug mode? if yes this may happen. the correct way to test is to view it in the right viewer. for example if its a xml file, would suggest downloading to local file and viewing in browser or some other xml tools