Accessing an XML-enabled Record

Once you have an XML-enabled record, you'll need to access it from the Procedure Division of your program. You can use existing COBOL verbs to do this and the XML-enhanced syntax for these verbs. See the topic XML Syntax Extensions for more information.

The following is a sample program with a Procedure Division that writes the contents of the widgets.xml file:

Sample COBOL program using XML

        $set p(prexml) endp
        select xml-stream assign "widgets.xml"
                          organization is xml
                          document-type is "widgets.xsd"
                          file status is file-status-spec.

        xd xml-stream.
	       copy "widgets.cpy".

        data division.
        working-storage section.
        01 file-status-spec PIC S9(9).

        procedure division.
          open output xml-stream
          write widgets
          display file-status-spec
          close xml-stream
        stop run.