Generating an EDI output in XML format

I need to save the output of the IDOC to EDI mapping in XML format, as in the final output has to be an XML file containing tags such as BGM etc. Any idea how this can be done? Is there any way of creating a XML schema for an EDI document

Have you tried pub.xml:documentToXMLString?

Thanks for the prompt reply and sorry as I made a mistake, since it is the first time I am posting to the wMusers community I did not ask the question with enough detail. Let me rephrase the question.
The XML that I need to generate has the field descriptions in it and not the field names. i.e. instead of ´BEG´ I have ´BeginingOfSegment´. So my real problem arises when I try and count the number of segments. I need a method that is versatile enough to count the apropriate nodes in the XML.
Also, I had to manually create the IS documents as I do not know of any other way in which such IS documents (containing the descriptions instead of the names) can be created.
Now I have 2 questions, What is the best way to create the schema and what is the best way to count the number of segments in the XML?

Creating the IS schema would need to be done by hand, if you need it. Another approach would be to create an XML schema using XMLSpy or other tool. Then use that to create an IS doc type and schema.

I’m tempted to ask why use description names instead of the segment names but I assume there’s some reason. BTW, BEG would be “BeginningSegment” not “BeginningOfSegment”.

As for counting segments that’s going to be a challenge. One approach that may work is to use the IS Java API to count the number of elements in your top level document. Other people may have other suggestions.

Thanks for the suggestions. And the reason why I need the XML it in such a way is because the client wants it that way … there are reasons for that also but I won´t get into the details and yes that BEG example is not entirely correct. :slight_smile: but just needed to get the point across. Thanks again