Skip to main content

Problem:

This demo shows how to parse XML

Resolution:

INTRODUCTION

==========

This example demonstrates the use of the Microsoft XML classes for manipulating Extensible Markup Language (XML) files.

This example will show how to use the methods within these OLE classes to parse an XML document into its various components. The file sample.xml contains the document used in this example. The document describes a list of musical compact discs divided into title, artist, tracks, price and track information.

This program will extract tag information from the XML object and will display the parsed data. It will also call the subprogram GetCDData using the XML object as a parameter and this program will further parse the document based on the values of certain tags.

This example also demonstrates the use of recursion within COBOL as the XML object is in a tree structure and the subprogram to extract data calls itself until the tree data is exhausted.

SOURCE FILES:

==========

Program Files             Description

---------------------      -----------------------------------------------------------

XMLPARSE.CBL          OO Program which will manipulate the sample.xml document using the

                                  Microsoft XML classes.

GETCDDATA.CBL       Subprogram called by XMLPARSE which will get the Title and Track

                                  information for each Compact Disc referenced in sample.xml.

TYPELIB.CPY             Copy file containing the interface definitions for the Microsoft XML classes

                                  and methods.

MFOLE.CPY               Copy file containing Net Express OLE constants and structures.

SAMPLE.XML              XML document which is loaded and parsed by the Calls to the Microsoft XML

                                  classes and methods.

REQUIREMENTS:

==========

The file sample.xml must be in the current directory.

OPERATION:

========

Rebuild this project to create the file xmlparse.exe. This will contain the programs xmlparse.obj and getcddata.obj.

==========================================================

Keywords: demonstration, sample, example, demo, web programming, xmlparse.zip

demo.ex

demo.ne

demo.se

Attachments:

xmlparse.zip

Old KB# 4210