Producing XML output

You can produce XML output from a COBOL program by using the XML GENERATE statement.

In the XML GENERATE statement, you identify the source and the output data items. You can optionally also identify:
  • A field to receive a count of the XML characters generated
  • The encoding for the generated XML document
  • A namespace for the generated document
  • A namespace prefix to qualify the start and end tag of each element, if you specify a namespace
  • A statement to receive control if an exception occurs

Optionally, you can generate an XML declaration for the document, and can cause eligible source data items to be expressed as attributes in the output rather than as elements.

You can use the XML-CODE special register to determine the status of XML generation.

After you transform COBOL data items to XML, you can use the resulting XML output in various ways, such as deploying it in a web service, writing it to a file, or passing it as a parameter to another program.

related references
Extensible Markup Language (XML)  
XML GENERATE statement (COBOL for AIX Language Reference)