Generating form based on XML and then taking input on that form and applying it to a new XML template.
Looking for any help as I've hit a mental block with this.
I have a set of XML documents that serve as templates. They tell you what elements are valid and available when you're actually writing up the XML document.
Usually you'd just manually write your XML based on this. I'm working on a tool that provides an actual form interface, using WPF.
So far I have a loop that goes through the nodes recursively, and based on the element type, runs a different function for each.
This is where I'm having an issue, I feel like there's a more efficient way through binding, templates or converters that I'm probably missing... I need to take each of these elements, store some of the attributes for XML generation, and also create a set of controls for those attributes that require user input. but I need to do it in a way that lets me then save the user input and combine it with the saved attributes in a new XML file.
What would be the best way to dynamically add controls from this loop, in a way that I can also take the user's input afterward and apply it back to a new XML document.
Example:
I need to take this template:
<Instance instance_type="buff" class="Buff" module="buffs.buff" muid="428AC54D9C8BCD1A" description="Main container class that holds all data for a buff and contains all the
accessors for the buff_tracker." > <many more elements in here> </Instance>
Turn it into a form, and when the user saves the form, get it into the format below:
string xml = String.Format("<I c=\"{0}\" i=\"{1}\" m=\"{2}\" n=\"{3}\">", xac["class"].Value, xac["instance_type"].Value, xac["module"].Value, "UsersInputFromGeneratedTextBox");
I hope I've explained myself well, I apologize if not.
0 comments:
Post a Comment