I am a first time poster, long time reader.
I have finally come across a problem that I cannot seem to find an answer to, and would love the help of the community to solve it!
So, the problem: I have this data (small excerpt) -
<region name="GLOBAL">
<light_dir_mult> 0.0020 0.0005 3.1000 10.0000 21.0000 22.9900 27.9900 29.5500 25.0660 18.0000 3.2000 1.0000 0.0099</light_dir_mult>
</region>
<region name="URBAN">
<light_dir_mult> 0.0020 0.0005 3.1000 10.0000 21.0000 22.9900 27.9900 29.5500 25.0660 18.0000 3.2000 1.0000 0.0099</light_dir_mult>
</region>
What I would like to be able to do, is load this data from a file, search for the 13 values between the open/close tags, and store them in 13 text boxes. This would need to be done twice for each "URBAN", and "GLOBAL" regions.
Additionally, after the values have been loaded into the text boxes, they would then need to be added back to the file with the exact same format they originated in. (After being edited by the user.)
I have devised a C# windows form solution, utilizing tabs to display the data based on regions. However, I have no idea how to properly search the file and store the 13 values accordingly :/
(The reason the values need to be stored in a text box, is due to the nature of the application. Its sole purpose is to provide an interface to edit these data files. Although the example provided shows one set of open/close tags, the original file contains thousands of different tags, and thus this process will need to be repeated multiple times, under different conditions.)
If anyone can think of an elegant solution to this problem, I would love to hear it!
EDIT:
Here is basically what I have so far, just simply loading the file.
private void loadFile()
{
OpenFileDialog file = new OpenFileDialog();
file.Title = "Open the xml weather file.";
file.Filter = "XML files|*.xml";
file.InitialDirectory = @"C:\";
if (file.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(file.FileName.ToString());
}
StreamReader sr = new StreamReader(file.FileName);
From here, I would need to find a way to search the file (using some sort of delimiter?) down to each "region" tag, then each "light_dir_mult" tag, then down again to separate each value. After I can manage to store each of the 13 values, they would then need to transferred into sperate textboxes.