CXmlMenu’�Display Menus from XML Files

Environment: VC6

This article covers the need for the dynamic creation of menus from XML files. Menus represent tree data structures exactly as XML files do. In case you have some data stored in an XML file and you want to select a specific item from it, wouldn’t it be nice to have something like this:


CXmlMenu menu;

//display the menu and get user selection
CString answer = menu.TrackXml(this,”example.xml”,”name”);

if (answer!=””)
MessageBox(“You selected \”” + answer + “\””);

This is exactly what the CXmlMenu class does. It can create a menu by reading a specific attribute of the items of an XML file (attribute “name” is selected in the example above); it displays the menu and returns the attribute of the selected item.

The code for XML file handling is taken from Pablo van der Meer.

Downloads


Download demo project – 129 Kb


Download source – 6 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read