Click here to Skip to main content
16,011,578 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

 
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 
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 
I get some more compiler errors as follows even after including msxml2.h in the stdafx.h.

--------------------Configuration: xmlparser - Win32 Debug--------------------
Compiling...
XmlParserDlg.cpp
e:\xml\xmlparser\xmlparserdlg.cpp(96) : error C2065: 'CLSID_DOMDocument2' : undeclared identifier
e:\xml\xmlparser\xmlparserdlg.cpp(96) : error C2065: 'IID_IXMLDOMDocument' : undeclared identifier
e:\xml\xmlparser\xmlparserdlg.cpp(101) : error C2027: use of undefined type 'IXMLDOMDocument'
c:\program files\microsoft xml parser sdk\inc\msxml2.h(56) : see declaration of 'IXMLDOMDocument'
e:\xml\xmlparser\xmlparserdlg.cpp(101) : error C2227: left of '->put_async' must point to class/struct/union
e:\xml\xmlparser\xmlparserdlg.cpp(105) : error C2027: use of undefined type 'IXMLDOMDocument'
c:\program files\microsoft xml parser sdk\inc\msxml2.h(56) : see declaration of 'IXMLDOMDocument'
e:\xml\xmlparser\xmlparserdlg.cpp(105) : error C2227: left of '->load' must point to class/struct/union
e:\xml\xmlparser\xmlparserdlg.cpp(110) : error C2027: use of undefined type 'IXMLDOMDocument'

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.