Click here to Skip to main content
15,892,746 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 334.3K   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

 
GeneralRe: Use XML4C from Apache/IBM Pin
Jamie Nordmeyer1-Nov-00 12:43
Jamie Nordmeyer1-Nov-00 12:43 
GeneralRe: Use XML4C from Apache/IBM Pin
Leo Davidson3-Nov-00 1:13
Leo Davidson3-Nov-00 1:13 
GeneralRe: Use XML4C from Apache/IBM Pin
20-Aug-01 7:53
suss20-Aug-01 7:53 
GeneralXML Version 3 beta (September) Pin
Ray Hayes31-Oct-00 1:36
Ray Hayes31-Oct-00 1:36 
GeneralIt is not Working Properly Pin
VenkataKrishnan.K31-Oct-00 0:30
sussVenkataKrishnan.K31-Oct-00 0:30 
GeneralRe: It is not Working Properly Pin
Ray Hayes31-Oct-00 0:49
Ray Hayes31-Oct-00 0:49 
GeneralRe: It is not Working Properly Pin
Brad Bruce31-Oct-00 1:42
Brad Bruce31-Oct-00 1:42 
GeneralCompile Error Pin
niv30-Oct-00 23:23
niv30-Oct-00 23:23 
--------------------Configuration: xmlparser - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
xmlparser.cpp
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(56) : error C2061: syntax error : identifier 'IXMLDOMDocument'
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(57) : error C2061: syntax error : identifier 'IXMLDOMParseError'
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(58) : error C2061: syntax error : identifier 'IXMLDOMNode'
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(59) : error C2061: syntax error : identifier 'IXMLDOMNode'
XmlParserDlg.cpp
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(56) : error C2061: syntax error : identifier 'IXMLDOMDocument'
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(57) : error C2061: syntax error : identifier 'IXMLDOMParseError'
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(58) : error C2061: syntax error : identifier 'IXMLDOMNode'
f:\xml\anmfcsample\xmlparser\xmlparserdlg.h(59) : error C2061: syntax error : identifier 'IXMLDOMNode'
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(92) : error C2065: 'IXMLDOMDocument' : undeclared identifier
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(92) : error C2065: 'pDoc' : undeclared identifier
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(92) : warning C4552: '*' : operator has no effect; expected operator with side-effect
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(97) : error C2065: 'CLSID_DOMDocument' : undeclared identifier
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(97) : error C2065: 'IID_IXMLDOMDocument' : undeclared identifier
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(102) : error C2227: left of '->put_async' must point to class/struct/union
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(106) : error C2227: left of '->load' must point to class/struct/union
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(109) : error C2065: 'IXMLDOMNode' : undeclared identifier
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(109) : error C2065: 'pNode' : undeclared identifier
F:\xml\anMFCSample\xmlparser\XmlParserDlg.cpp(109) : warning C4552: '*' : operator has no effect; expected operator with side-effect
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 

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.