C$XML

This routine lets you retrieve and parse precise information from an XML document. It also lets you add, modify, or delete data in an XML document.

Refer to the Guide to Interoperating with ACUCOBOL-GT, Working with Non-Vision Data for additional user instructions, examples, and help with XML terminology like element, attribute, parent, child, and sibling.

Usage

CALL "C$XML" 
    USING OP-CODE, parameters...

Parameters

OP-CODE Numeric parameter

Specifies the operation to perform. These are defined in their own topics. There are constants defined for the op-codes in acucobol.def.

Parameters Vary depending on the op-code chosen.

The parameters vary depending on the operation selected. They provide information and hold results for the operations specified. These are described in the applicable op-code topic.

Comments

This utility gives you low-level control over the parsing of XML data. If you do not require such precise control or if you would prefer to use a transparent interface to map XML to COBOL, you can use AcuXML to parse the XML data instead. AcuXML is a file system interface that is designed to map XML data to COBOL based on eXtended File Descriptors (XFDs) create at compile time. See Working with XML Data for more information.

The C$XML routine is useful for parsing all XML files, including non-records-based XML files such as XFDs or configuration files that you have formatted in XML. AcuXML is not able to parse XML documents such as these, because it quits after the close of the first top-level element, considering that to be the end of the file. AcuXML is useful strictly for records-based XML files.

The following C$XML op-codes all take a parameter which is a regular expression:

  • CXML-GET-SIBLING-BY-ATTR-NAME
  • CXML-GET-SIBLING-BY-CDATA
  • CXML-GET-SIBLING-BY-ATTR-VALUE
  • CXML-GET-CHILD-BY-ATTR-VALUE
  • CXML-GET-CHILD-BY-CDATA
  • CXML-GET-CHILD-BY-NAME
  • CXML-GET-CHILD-BY-ATTR-NAME
  • CXML-GET-SIBLING-BY-NAME
  • CXML-GET-ATTRIBUTE-BY-NAME
  • CXML-GET-LAST-ERROR

If unexpected results are seen, the AREGEXP_COMPILE_NO_REGEXP flag may be required. This causes a search for the text, rather than a regular expression. See op-code 2 of C$REGEXP for a complete list of flags.