Skip to Content

encoding xml file from ISO-8859-1 to utf-8

Feb 14, 2017 at 05:56 PM


avatar image

Hello SAP Community,

I've a xml document that appears to have been written with utf-8 but have the encoding 8859-1. (I've changed in the notepad from 8859 to utf-8 and SAP read the file correctly).

Without changing the xml file how can i force the encoding in the abap?

The code seams not to work.


data encoding(10) value 'UTF-8'.

* Creating a document
l_document = l_ixml->create_document( ).

* encoding
l_encoding = encoding.
i_encoding = l_ixml->create_encoding( character_set = l_encoding
byte_order = '0' ).
l_document->set_encoding( encoding = i_encoding ).

* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).

the file is opend with

call method cl_gui_frontend_services=>gui_upload
filename = l_filename
filetype = 'BIN'
filelength = l_xml_table_size
data_tab = l_xml_table
others = 19.

What i'm doing wrong?

Thanks. Regards,

Maria João Rocha

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sandra Rossi Feb 14, 2017 at 06:09 PM

I guess the only solution is to modify the xml in memory, between GUI_UPLOAD and PARSE.

Of course, the best solution is to ask for a correct XML file!

10 |10000 characters needed characters left characters exceeded
Maria João Paulo Rocha Feb 15, 2017 at 09:53 AM

Yes the best solution would be the correct xml, but I'm afraid that is not possible...

I wish create_encodingworked on the abap code!


Maria João Rocha

10 |10000 characters needed characters left characters exceeded