General procedure

When using the C$XML routine, you should perform the following basic functions:

  1. Parse an XML file.
  2. Move to an element in the file.
  3. Retrieve data from the element.
  4. Add, modify, or delete data as desired.
  5. Write to the file to save your changes.
  6. Release the parser from memory.

If an error occurs, you can also retrieve error information. If desired, you can retrieve element attributes or comments as well.

Each function is performed through C$XML operation codes (op-codes) as described in this section. Most C$XML operations return element handles. A separate handle is provided for each element. You should move the return codes to an ACUCOBOL-GT handle that you've declared in Working-Storage. The handle should be defined as USAGE IS HANDLE. You will refer to these handles when you move deeper into a record and retrieve or update specific data.

refer to C$XML Examples for sample code.

Note: You don't necessarily have to open a file to read XML data. You can parse a string directly using the CXML-PARSE-STRING op-code.