Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Example: parsing a simple document

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.

Table 1. XML events and special regisers
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  

related references    
XML-EVENT  
XMLPARSE (Compiler option)
    
XML PARSE (Enterprise COBOL Language Reference)
    


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)