Skip to Content
Author's profile photo Uwe Schieferstein

Visualizing Any Kind of XML Data Using Class CL_XML_DOCUMENT


When dealing with the manipulation of XML data (e.g. XSLT transformation, ABAP class mapping) we often face the problem to visualize the changed XML data in an easy way. As a consequence we usually need more iterations to adjust our program logic in order to get the required results.

Another challenge is when we receive XML data as xstring input. If errors occur how can we exclude (or confirm) that the XML was erroneous? Example: The input of the eBPP Customer component are base64-encoded DocumentSets. During the processing of these records XML INVOIC-IDocs are generated.

Finally, another trigger to write this blog was a comment to Michal Krawczyk‘s blog (The specified item was not found. requesting for a better output of the XML data.


Further Readings:

Upload XML file to internal table


Class CL_XML_DOCUMENT – The jack-of-all-trades

The following piece of coding shows that as soon as you have created an instance of CL_XML_DOCUMENT you are just 2 simple steps away from displaying XML data received as xstring:

(1) Parse the XML Stream (XString) to DOM

(2)  Display document


The XML document is displayed in a HTML viewer. In order to search through the XML simply use CTRL+F.




Irrespective of whether the XML input is provided as file, internal itab, string, or xstring class CL_XML_DOCUMENT provides the appropriate methods for loading (file) or parsing the XML input (not shown; see Appendix: report ZUS_SDN_XML_DISPLAY).


Use Cases for XML Visualization

Currently I have 2 Use Cases in which I apply the versatility of class CL_XML_DOCUMENT:

(1) All ABAP class mapping on SAP-PI have a static TEST method in which I can display the XML before and after the mapping.

(2) eBPP Customer (Troubleshooting): As soon as I execute processing of DocumentSets in Debugging mode I can display the intermediate XML-IDocs in the HTML viewer for visual inspection. 



Whenever you need to quickly visualize XML data take advantage of the versatile methods of class CL_XML_DOCUMENT




Coding of sample report ZUS_SDN_XML_DISPLAY.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hello Uwe,

      As always a very nice read.

      Quite a long time back i had posted a Wiki on how to upload an XML file into ABAP internal table using CL_XML_DOCUMENT:

      My Use Case: Build an ABAP tool to read the input XMLs & compare their structures. I wouldn't go into the specifics, it's too complicated to explain the entire scenario 🙂


      PS: I find this class to be much easier to use than the XSLT tool!

      Author's profile photo Uwe Schieferstein
      Uwe Schieferstein
      Blog Post Author
      Hello Suhas

      Please apologize that I did not search more carefully. I scanned only through the existing Blogs on this topic. I have added you link as additional reference.


      Author's profile photo Former Member
      Former Member

      Hi Suhas,

                I have a requiremment where in there are multiple tabs in an excel sheet which is being stored in an xml format which I will have to read into internal tables again, is this possible with the class method you have suggest? I see that this is for presentation server, does it work for app server too?

      Please do let me know...

      Thanks & Regards,