Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - VB6 Go to Specific Node >Thread Next - Re: VB6 Go to Specific Node Re: VB6 Go to Specific NodeTo: NULL Date: 5/2/2004 2:24:00 PM Matthew Shaw wrote: > I have several command buttons, each with their own menu (popup). I use an > XML file to set the captions of the command buttons and their corresponding > menus. My XML file is arranged like this: > > <places> > <section> > <!-- Command button properties--> > <name></name> > <description</description> > > <!-- Menu properties --> > <menu></menu> > <menu></menu> > </section> > <!-- ...and more <sections> --> > </places> > > Each button has it's own <section>. I loop through the nodes (for each) > > Basically, I want my program to be able to determine what to do when the > user clicks a menu item based on keywords associated with each menu. Thus I > am thinking maybe each <menu> item has an attribute (correct name?) > associated with it, which is the keyword, so each menu item would be like > <menu function="openfile">. > > My program can provide the command button's index, which is what number > <section> it got its contents from (ie. the first command button's caption > and corresponding menu would have been from the first <section> tree), and I > can supply the menu's index, (ie. if the user clicks the second item on the > popup menu then we know that it was from the first <menu> item of a > particular <section>. > > I am thinking that I loop through a certain number of <section> items > according to the command button number pressed (ie. I press the first > command button so it goes to the first <section> tree). Then, under that > <section> tree, it reads the n'th <place> item's attribute - where n is the > number of the menu clicked (ie. if I click the third menu item, then the > third <place> attribute is read). > > I hope I explained myself okay, I'm new to XML and it is kind of hard to > find VB6 XML info. Basically, the end question is, how to do I go to one > specific <section> tree (number is determined by the command button number > pressed) and then read a specific <place> attribute (number is determined by > menu item pressed). MSXML 3 and 4 support XPath and XPath supports indexing a node set e.g. //section[3]//menu[4] where indices start from 1 so the above would select the third <section> element and then the fourth <menu> in that. The method to call is xmlDocument.selectSingleNode, the argument is the XPath as a string e.g. Set menu = xmlDocument.selectSingleNode("//section[3]//menu[4]") -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
