-------------------------------------------------------------------------------------------------
DATA : lr_ixml TYPE REF TO if_ixml,
lr_doc TYPE REF TO if_ixml_document,
lr_root_elem TYPE REF TO if_ixml_element,
lr_node1_elem TYPE REF TO if_ixml_element,
lr_stream TYPE REF TO if_ixml_stream_factory,
lr_ostream TYPE REF TO if_ixml_ostream,
lr_render TYPE REF TO if_ixml_renderer,
xml_string TYPE string.
lr_ixml = cl_ixml=>create( 0 ).
* Get reference of the document
lr_doc = lr_ixml->create_document( ).
* get reference of the root
lr_root_elem = lr_doc->create_simple_element_ns( prefix = 'asx'
name = 'test'
parent = lr_doc ).
* Add root element attributes
lr_root_elem->set_attribute_ns( name = 'asx'
prefix = 'xmlns'
value = 'http://www.sap.com/testxml' ).
lr_root_elem->set_attribute_ns( name = 'version'
value = '1.0' ).
* Get reference of the first node of teh root
lr_node1_elem = lr_doc->create_simple_element_ns( prefix = 'asx'
name = 'names'
parent = lr_root_elem ).
* add node 1 to the document
lr_doc->create_simple_element_ns( name = 'name'
value = 'SAP'
parent = lr_node1_elem ).
lr_stream = lr_ixml->create_stream_factory( ).
lr_ostream = lr_stream->create_ostream_cstring( xml_string ).
lr_render = lr_ixml->create_renderer( document = lr_doc
ostream = lr_ostream ).
lr_render->render( ).
cl_abap_browser=>show_xml(
EXPORTING
xml_string = xml_string
title = 'Test XML'
size = cl_abap_browser=>medium ). " Size (S,M.L,XL)
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
DATA : lr_ixml TYPE REF TO if_ixml,
lr_doc TYPE REF TO if_ixml_document,
lr_root_elem TYPE REF TO if_ixml_element,
lr_node1_elem TYPE REF TO if_ixml_element,
lr_stream TYPE REF TO if_ixml_stream_factory,
lr_ostream TYPE REF TO if_ixml_ostream,
lr_render TYPE REF TO if_ixml_renderer,
xml_string TYPE string.
lr_ixml = cl_ixml=>create( 0 ).
* Get reference of the document
lr_doc = lr_ixml->create_document( ).
* get reference of the root
lr_root_elem = lr_doc->create_simple_element_ns( prefix = 'asx'
name = 'test'
parent = lr_doc ).
* Add root element attributes
lr_root_elem->set_attribute_ns( name = 'asx'
prefix = 'xmlns'
value = 'http://www.sap.com/testxml' ).
lr_root_elem->set_attribute_ns( name = 'version'
value = '1.0' ).
* Get reference of the first node of teh root
lr_node1_elem = lr_doc->create_simple_element_ns( prefix = 'asx'
name = 'names'
parent = lr_root_elem ).
* add node 1 to the document
lr_doc->create_simple_element_ns( name = 'name'
value = 'SAP'
parent = lr_node1_elem ).
lr_stream = lr_ixml->create_stream_factory( ).
lr_ostream = lr_stream->create_ostream_cstring( xml_string ).
lr_render = lr_ixml->create_renderer( document = lr_doc
ostream = lr_ostream ).
lr_render->render( ).
cl_abap_browser=>show_xml(
EXPORTING
xml_string = xml_string
title = 'Test XML'
size = cl_abap_browser=>medium ). " Size (S,M.L,XL)
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
No comments:
Post a Comment