I would like to know how I could generate code from a text file in a particular format into a VB.net or C# source file.
For instance: I would like my code generating program to read text file having the following format:
<category1>
<subcategory>
entry1
entry2
</subcategory>
</Category1>
And then generate code in vb.net(or C#):
Dim TreeNode1 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("entry1")
Dim TreeNode2 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("entry2")
Dim TreeNode3 As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("subcategory", New System.Windows.Forms.TreeNode() {TreeNode1, TreeNode2})
The idea is to compile the main code after the user have modified the txt file and used the code generating program. I would prefer to write the code generating program in C, python or C#.
How can I go about this?
I’m not really convinced this is a python question, despite the tags and penultimate sentence in the question, but here’s a python answer.