ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Class Libraries for XML → sXML Library → sXML Library, Examples
sXML Library, Transformation from XML Reader
Deserializes ABAP data from an XML reader.
Other versions:
7.31 | 7.40 | 7.54
Source Code
REPORT demo_sxml_trafo_from_reader.
CLASS sxml_demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS sxml_demo IMPLEMENTATION.
METHOD main.
DATA(xml) = cl_abap_conv_codepage=>create_out( )->convert(
`<document>` &&
` <head>` &&
` <author>KELLERH</author>` &&
` <date>20120824</date>` &&
` </head>` &&
` <body>` &&
` <asx:abap` &&
` xmlns:asx="http://www.sap.com/abapxml" version="1.0">` &&
` <asx:values>` &&
` <TABLE>` &&
` <item>1</item>` &&
` <item>2</item>` &&
` <item>3</item>` &&
` </TABLE>` &&
` </asx:values>` &&
` </asx:abap>` &&
` </body>` &&
`</document>` ).
DATA(reader) =
CAST if_sxml_reader( cl_sxml_string_reader=>create( xml ) ).
WHILE reader->name <> 'body'.
reader->next_node( ).
ENDWHILE.
DATA itab TYPE TABLE OF i.
CALL TRANSFORMATION id SOURCE XML reader
RESULT table = itab.
cl_demo_output=>display( itab ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
sxml_demo=>main( ).
Description
An XML string reader parses the XML data of a byte string until it reaches the element <body>. The element <header> is not analyzed further. The reader located at the opened <body> element is used as an XML source for the identity transformation ID. The content of <body> is in asXML format for an internal table, which means it can be deserialized to this table.