I wonder, whether it would be possible to build a context menu dynamically from the contents of the selected XML file by parsing its nodes.
In my case, the XML file is an Apache Ant build file, whose <target>
element's @name
attribute I read into an array. This gives me something like ["default","init","clean","mkdirs","release","etc."]
, which represents the list of build targets. A Build menu's sub items would be built from this array. Each of the items would then run Apache Ant with the selected target passed to it.
I have written a little script, that does exactly this, up to the results of my DOM parsing. Now, that I have the array ready, I don't know how to continue. First I'd need to setup a context menu for this filetype. Let's call it Build. It contains a row of sub menu items, the topmost being the one, that gets executed as default, which simply would build the whole package, but beneath this, a single target could be chosen, selecting one would simply issue a DOS command ant <targetname>
.
The question now is: can I create the sub items of a menu dynamically from a script, each time I open it?
The result then would look something like this:
Build
Build (default)
init
clean
mkdirs
release
etc.
Thanks.