What is the best way to fill a template file with variables, which are collected from a Windows Form or Web Page. I want to create a wizard program that collects some data from user, for instance, reportname, reporttype, etc. and I need to create then some xml files (templates) with these variables inserted.
Share
Well, first you need to save those variables somewhere, like a class or a Hashtable.
Then you load the xml file.
Then for each variable you select the proper node (using xpath) and change the inner contents to the variable value, like this:
The best way to make this all automatic would be saving both xpaths and the variables names into a dictionary/hashtable and these use it to lookup where a variable goes.
You would then save the file.
Note: Ask for more information regarding the mapping if you didn’t understand it.