Click here to Skip to main content
11,701,855 members (62,460 online)
Click here to Skip to main content

A Simple XML DOM Viewer/Navigator Using MC++

, 23 Sep 2004 66.3K 2K 29
Rate this:
Please Sign up or sign in to vote.
A simple GUI written in MC++ providing a DOM tree and XPath navigator for XML files

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

Share

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...

You may also be interested in...

Comments and Discussions

 
QuestionWon't compile using VS 2010 Pin
Michael B Pliam31-May-13 15:53
memberMichael B Pliam31-May-13 15:53 
Generalxpath with date Pin
mathuros_paiboon15-Aug-05 23:15
membermathuros_paiboon15-Aug-05 23:15 
Generaldasdas Pin
Anonymous26-Sep-04 21:07
sussAnonymous26-Sep-04 21:07 
GeneralIE with XPATH Pin
Anonymous24-Sep-04 6:50
sussAnonymous24-Sep-04 6:50 
GeneralRe: IE with XPATH Pin
liyang yu24-Sep-04 9:02
memberliyang yu24-Sep-04 9:02 
GeneralRe: IE with XPATH Pin
amitDeepak26-Sep-04 18:58
memberamitDeepak26-Sep-04 18:58 
GeneralRe: IE with XPATH Pin
liyang yu27-Sep-04 4:12
memberliyang yu27-Sep-04 4:12 
XML files are just text files which hold information. The final goal is still to use these text files in your applications.

When it comes to building XML applications, there are mainly two models and these models enable the creation of APIs you can use in your own XML applications to analyze or manipulate XML structures. One of the two models is Document Object Model (DOM), the other one is the Simple API for XML (SAX).

You can find more details about DOM and SAX from the internet, and I like this one a lot: http://www-136.ibm.com/developerworks/xml/[^]


GeneralRe: IE with XPATH Pin
Anonymous27-Sep-04 7:28
sussAnonymous27-Sep-04 7:28 
GeneralRe: IE with XPATH Pin
liyang yu27-Sep-04 9:04
memberliyang yu27-Sep-04 9:04 
GeneralRe: IE with XPATH Pin
Anonymous27-Sep-04 1:55
sussAnonymous27-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 | Terms of Use | Mobile
Web03 | 2.8.150819.1 | Last Updated 23 Sep 2004
Article Copyright 2004 by liyang yu
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid