Click here to Skip to main content
Click here to Skip to main content

A Simple XML DOM Viewer/Navigator Using MC++

By , 23 Sep 2004
Rate this:
Please Sign up or sign in to vote.

1. Introduction

This article presents a simple GUI written in VC++.NET 2003, its main features include showing a XML file in a treeView and navigating through the XML data by using XPath expressions. It was mainly developed for my own need: from time to time in my work, I often felt it would be very convenient if I had a simple GUI to "preview" the XML file the system generated or received before I take steps further to implement any processing to it - it could be used as a tool to simply confirm "everything is okay". I could have used IE to open the XML file, but IE does not provide any "intelligent" navigation through the data. Sometimes, the XML file can be very big, therefore, it would be very helpful to combine the "viewing" function together with the "navigating" function. So here it is, using this small tool, I can view the XML file and also carry out a search in the file.

I hope you find this small tool useful and if you are just beginning your development work with VC++.NET, you can then use this example to study how easy to process XML files using MC++. You can also download the source code and maybe you will be motivated enough to add some more features to it, and I am sure you will then find it very helpful to your daily work.

2. Using the code

You may directly download the executable or you may download the source code and build it in Visual Studio.NET 2003. When you try to open a XML file, a file selection dialog will show up. After you select the file, you can build the treeview of the XML file by clicking "build" button. You can then type XPath expressions to navigate in the tree.

XPath provides a more efficient way to locate data in a DOM tree. Just to make this small article complete, the following are some examples about how to use XPath expression (see the XML file in the screen shot):

/personnel/person:

this will match all the person nodes that are child nodes of personnel and personnel must be a root element node;

/personnel/person[email='one@foo.com']:

this will find all the person whose email is one@foo.com.

I think the above examples are pretty much enough. If you provide a wrong expression, this small tool will show you some basic information, letting you know that something is wrong. Also, you can use the clear button to start over.

3. That is it!

Okay, hope you find it useful, also look forward to seeing new features added to it!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

liyang yu
Web Developer
United States United States
I love to tell jokes and today, I finally came up with my own joke. here it goes:
 
I decide to make my first son a medical doctor so later on when I am old and sick, I can get medical care any time I need and for free..., in fact, better to make my second son a medical doctor too so I can get a second opinion.
 
here is another version of this joke:
 
I decide to make my first son a medical doctor so later on when I am old and sick, I can get medical care any time I need and for free..., in fact, better to make my second son a medical doctor too so I can get a second opinion. well, perhaps my third son should be a lawyer - in case something is wrong with my medical care, I can sue the first two for free.
 
if you happen to visit this page and read these two jokes, tell me which one you like...

Comments and Discussions

 
QuestionWon't compile using VS 2010 PinmemberMichael B Pliam31-May-13 15:53 
Generalxpath with date Pinmembermathuros_paiboon15-Aug-05 23:15 
Generaldasdas PinsussAnonymous26-Sep-04 21:07 
GeneralIE with XPATH PinsussAnonymous24-Sep-04 6:50 
GeneralRe: IE with XPATH Pinmemberliyang yu24-Sep-04 9:02 
GeneralRe: IE with XPATH PinmemberamitDeepak26-Sep-04 18:58 
GeneralRe: IE with XPATH Pinmemberliyang yu27-Sep-04 4:12 
GeneralRe: IE with XPATH PinsussAnonymous27-Sep-04 7:28 
GeneralRe: IE with XPATH Pinmemberliyang yu27-Sep-04 9:04 
GeneralRe: IE with XPATH PinsussAnonymous27-Sep-04 1:55 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 23 Sep 2004
Article Copyright 2004 by liyang yu
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid