Click here to Skip to main content
15,867,453 members
Articles / Programming Languages / Objective C

A Simple XML DOM Viewer/Navigator Using MC++

Rate me:
Please Sign up or sign in to vote.
3.89/5 (9 votes)
23 Sep 20043 min read 80.4K   2.1K   28   11
A simple GUI written in MC++ providing a DOM tree and XPath navigator for XML files

Image 1

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


Written By
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 Pin
Michael B Pliam31-May-13 15:53
Michael B Pliam31-May-13 15:53 
Generalxpath with date Pin
mathuros_paiboon15-Aug-05 23:15
mathuros_paiboon15-Aug-05 23:15 
Generaldasdas Pin
Anonymous26-Sep-04 21:07
Anonymous26-Sep-04 21:07 
dasdasdasdasdasdasdasdasdasdasd
GeneralIE with XPATH Pin
Anonymous24-Sep-04 6:50
Anonymous24-Sep-04 6:50 
GeneralRe: IE with XPATH Pin
liyang yu24-Sep-04 9:02
liyang yu24-Sep-04 9:02 
GeneralRe: IE with XPATH Pin
amitDeepak26-Sep-04 18:58
amitDeepak26-Sep-04 18:58 
GeneralRe: IE with XPATH Pin
liyang yu27-Sep-04 4:12
liyang yu27-Sep-04 4:12 
GeneralRe: IE with XPATH Pin
Anonymous27-Sep-04 7:28
Anonymous27-Sep-04 7:28 
GeneralRe: IE with XPATH Pin
liyang yu27-Sep-04 9:04
liyang yu27-Sep-04 9:04 
GeneralRe: IE with XPATH Pin
Anonymous27-Sep-04 1:55
Anonymous27-Sep-04 1:55 

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.