Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

IF_IXML : How can i add encoding with value UTF-8 to the document object??


i want to create a xml file with the following content:

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

<OpenSearchDescription xmlns="http://....">


i did this with the if_ixml interface and rendered the content in a file 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml

<?xml version="1.0"?>

<OpenSearchDescription xmlns="http://....">


BUT the document attribut(?) encoding="UTF-8"?> is missing!

How can i add encoding with value UTF-8 to the document object?? it should look like:

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


*here is my coding.



DATA: lo_ixml TYPE REF TO if_ixml,

lo_streamfactory TYPE REF TO if_ixml_stream_factory,

lo_document TYPE REF TO if_ixml_document,

lo_parent TYPE REF TO if_ixml_element,

lo_ostream TYPE REF TO if_ixml_ostream,

lo_renderer TYPE REF TO if_ixml_renderer,

lv_rc TYPE i.

lo_ixml = cl_ixml=>create( ).

lo_streamfactory = lo_ixml->create_stream_factory( ).

lo_document = lo_ixml->create_document( ).

lo_parent = lo_document->create_simple_element( name = 'OpenSearchDescription' "root node

parent = lo_document ).

lo_parent->set_attribute_ns( name = 'xmlns'

value = 'http://....' ).

*rausrendern in file

lo_ostream = lo_streamfactory->create_ostream_uri( system_id = 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml' ).

lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream

document = lo_document ).

lv_rc = lo_renderer->render( ).


Thanks for help


Former Member
Former Member replied

Use the following code:

  • set an document encoding

l_encoding = l_ixml->create_encoding( character_set = 'UTF-8'

byte_order = if_ixml_encoding=>co_none ).

l_success = l_ostream->set_encoding( encoding = l_encoding ).

  • create a xml renderer

l_renderer = l_ixml->create_renderer( document = l_doc ostream = l_ostream ).

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question