Accessing XML documents

Before you can parse an XML document using an XML PARSE statement, you must make the document available to your program. Common methods of acquiring an XML document are by retrieval from a WebSphere® MQ message, a CICS® transient queue or communication area, or an IMS message processing queue; or by reading the document from a file.

About this task

If the XML document that you want to parse is held in a file, use ordinary COBOL facilities to place the document into a data item in your program:

  • A FILE-CONTROL entry to define the file to your program.
  • An OPEN statement to open the file.
  • READ statements to read all the records from the file into a data item (either an elementary item of category alphanumeric or national, or an alphanumeric or national group). You can define the data item in the WORKING-STORAGE SECTION or the LOCAL-STORAGE SECTION.
  • Optionally, the STRING statement to string all of the separate records together into one continuous stream, to remove extraneous blanks, and to handle variable-length records.

If the XMLPARSE(XMLSS) option is in effect, you can parse an XML document that is in a file by passing the parser one record (or segment) of text from the file at a time. This capability is useful for parsing very large XML documents.

Related references  
XMLPARSE (compiler option)