Although short, the following sample XML document contains many XML events. These events are shown below the document in the order in which they would occur during parsing, and the exact text for each XML event is delimited by angle brackets (<<>>).
In general, this text can be the content of either XML-TEXT or XML-NTEXT. The sample XML document below does not contain any text that requires XML-NTEXT, however, and thus uses only XML-TEXT.
This example begins with an XML declaration. If an XML declaration occurs in a document that you are parsing, the declaration must begin in the first byte of the document; otherwise, the parser generates an exception code. The attribute names that are coded in the XML declaration must all be in lowercase characters.
<?xml version=“1.0” encoding=“ibm-1140” standalone=“yes” ?> <!--This document is just an example--> <sandwich> <bread type=“baker's best” /> <?spread please use real mayonnaise ?> <meat>Ham & turkey</meat> <filling>Cheese, lettuce, tomato, etc.</filling> <![CDATA[We should add a <relish> element in future!]]> </sandwich>junk
Notice that the value of the type attribute in the sample consists of three fragments: the string 'baker', the single character ''', and the string 's best'. The single-character fragment ''' is passed separately as an ATTRIBUTE-CHARACTER event.
<<'>>
Notice that the content of the meat element in the sample consists of the string 'Ham ', the character '&', and the string ' turkey'. The single-character fragment '&' is passed separately as a CONTENT-CHARACTER event. Also notice the trailing and leading spaces, respectively, in these two string fragments.
related concepts
The content of XML-TEXT and XML-NTEXT
related tasks
Parsing XML documents
Writing procedures to process XML
related references
The content of XML-EVENT
XML-EVENT
(COBOL for Windows Language Reference)
4.6 Predefined entities (XML specification)
2.8 Prolog and document type declaration (XML specification)