Click here to Skip to main content
16,011,647 members
Articles / Web Development / HTML

XML Parser Demo

Rate me:
Please Sign up or sign in to vote.
4.71/5 (21 votes)
29 Oct 2000CPOL 339.2K   5.1K   46   50
Using the Microsoft XML (MSXML) parser.

Introduction

In an attempt to learn how to exploit XML (eXtensible Mark-up Language) within my applications, I have found a very few demonstration applications to assist me in getting started. The documentation and examples in the Platform SDK for using the Microsoft XML Parser (built into Internet Explorer 4+, although I'm using IE5) all seem to be for Visual Basic/VBScript and not for C++/MFC.

In this sample application I've simply tried to parse a XML file and visualise it as a basic tree view. The code recursively walks through both then ELEMENTS and ATTRIBUTES of the document. Some of the known element types are given an identifying icon and some of the contents/values are expressed too.

Included within the .Zip file is my first XML file including a DTD (Document Type Definition).

XML Parser
Figure 1 - Sample XML Parser Dialog

Parsing errors detected by the MSXML object are displayed within a message box and locate the problem location within the XML document.

 

Parser Error
Figure 2 - Parser Error Report

See the source code for the parser code - it's quite simple.

If you're interested, the long term aim of this file is to provide an externally configurable definition for toolbar and menu layouts within my applications. Due to the nature of the customer, end-user customisation is not applicable yet the specifications for what is wanted is likely to come through after I've left the project.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralCompile Error Pin
niv30-Oct-00 23:23
niv30-Oct-00 23:23 
GeneralRe: Compile Error Pin
Ray Hayes30-Oct-00 23:46
Ray Hayes30-Oct-00 23:46 
GeneralRe: Compile Error: Include the Following Lines Pin
VenkataKrishnan.K31-Oct-00 0:48
sussVenkataKrishnan.K31-Oct-00 0:48 
GeneralRe: Compile Error: Include the Following Lines Pin
EZ31-Oct-00 9:50
EZ31-Oct-00 9:50 
GeneralRe: Compile Error: Include the Following Lines Pin
Adrian31-Oct-00 19:18
Adrian31-Oct-00 19:18 
GeneralRe: Compile Error: Include the Following Lines Pin
Praveen KR9-May-01 18:03
Praveen KR9-May-01 18:03 
GeneralRe: Compile Error: Include the Following Lines Pin
11-May-01 0:38
suss11-May-01 0:38 
GeneralRe: Compile Error: Include the Following Lines Pin
sterding7-Apr-02 2:07
sterding7-Apr-02 2:07 
Now I can run the programme!
But it can't parse any existing xml file!I had debug it step by step and find the following line always is FALSE!

SUCCEEDED (CoCreateInstance(CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument,
reinterpret_cast<void**>(&pDoc))))

Why?Please give me your option!thanksConfused | :confused:

sterding

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.