Enterprise COBOL provides an event-based interface that enables you to parse XML documents and transform them to COBOL data structures.
The XML parser finds fragments (associated with XML events) within the document, and your processing procedure acts on those fragments. You code your procedure to handle each XML event. Throughout this operation, control passes back and forth between the parser and your procedure.
You start this exchange with the parser by using the XML PARSE statement, in which you designate your processing procedure. Execution of the XML PARSE statement begins the parsing and establishes your processing procedure with the parser. The parser transfers control to your processing procedure for each XML event that it finds in the document. After processing the event, your processing procedure returns control to the parser. Each normal return from your procedure causes the parser to continue analyzing the XML document to report the next event. You can also specify in the XML PARSE statement two imperative statements to which you want control to be passed at the end of the parsing: one when a normal end occurs and one when an exception condition exists.
The following figure shows a high-level overview of the basic exchange of control between the parser and your program.
Normally, parsing continues until the entire XML document has been parsed.
When the XML parser parses XML documents, it checks them for most aspects of well formedness. A document is well formed if it adheres to the XML syntax in the XML specification and follows some additional rules such as proper use of end tags and uniqueness of attribute names.
related tasks
Accessing XML documents
Parsing XML documents
Writing procedures to process XML
Understanding the encoding of XML documents
Handling XML PARSE exceptions
Terminating XML parsing
related references
XML specification