09-03-2008 12:58 PM
Hi
i want to create a xml file with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://....">
</OpenSearchDescription>
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://....">
</OpenSearchDescription>
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.
TYPE-POOLS: ixml.
CLASS cl_ixml DEFINITION LOAD.
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
Britta
09-03-2008 1:34 PM
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 ).
09-03-2008 1:34 PM
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 ).
09-03-2008 2:06 PM
Hi sanjay
thank you very much for your answer.
It worked perfectly .
thanks again
and
best regards
britta
04-29-2016 11:49 PM
Hi Britta,
I have doubt.
How did you get 'http:\\' into your code?
Is it working fine.Because when i write the same it goes for dump.
04-30-2016 8:40 AM
You have to write a valid URI of course: http://... stands for http:// followed by something (for instance http://xx.com)