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 from a parameter to your program 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.