SAP gives function modules that you can export SAP IDOC to XML files. It is really useful for integration Consultant / Developer to do mapping unit test and data checking, searching.
In this article, i will show you a simple function module to export XML files.

In SAP ECC, SAP HANA, SAP S/4 HANA, SAP CAR, ect…we can search Inbound / Outbound IDoc you want to download by Tcode: WE02

STEP 01: Access function builder, TCode: SE37

STEP 02: Execute function module: IDOC_XML_TRANSFORM

STEP 03: View IDOC content

STEP 04: Copy Payload result

STEP 05: replace all tag spaces

STEP 06: Use Notepad++ and XML plugin to format XML file

Thanks and hope useful for you.
Cuong Dang