This example shows the flow of events and the related contents of special register XML-TEXT for parsing an elementary XML document.
Assume that the COBOL program contains the following elementary XML document in data item Doc:
<?xml version="1.0"?><msg type="short">Hello, World!</msg>
The following code fragment shows the XML PARSE statement for parsing Doc and a processing procedure, P, for handling XML events:
XML Parse Doc Processing procedure P ... P. Display XML-Event XML-Text.
The processing procedure displays the content of XML-EVENT and XML-TEXT for each event that the parser signals during parsing. The table below shows the result.
| XML-EVENT | XML-TEXT |
|---|---|
| START-OF-DOCUMENT | |
| VERSION-INFORMATION | 1.0 |
| START-OF-ELEMENT | msg |
| ATTRIBUTE-NAME | type |
| ATTRIBUTE-CHARACTERS | short |
| CONTENT-CHARACTERS | Hello, World! |
| END-OF-ELEMENT | msg |
| END-OF-DOCUMENT |
related concepts
XML-TEXT and XML-NTEXT