I am using the following code to create an xml file to run on form load if the file is not found:
XElement xml = new XElement("Config",
new XElement("wStatus", ""),
new XElement("wStatus", "1"),
new XElement("wStatus", "2"),
new XElement("wStatus", "3"),
new XElement("wCode", ""),
new XElement("wCode", "AAAA"),
new XElement("wCode", "BBBB"),
new XElement("wCode", "CCCC"),
new XElement("wRegion", "A")
);
xml.Save(Application.StartupPath + "\\config.xml");
I would like to update this code so I can put parent tags around each different set of data so a revised version of the above would look like the following:
<?xml version="1.0" encoding="utf-8"?>
<Config>
<mStatus>
<wStatus>1</wStatus>
<wStatus>2</wStatus>
<wStatus>3</wStatus>
</mStatus>
<mCode>
<wCode>AAAA</wCode>
<wCode>BBBB</wCode>
<wCode>CCCC</wCode>
</mCode>
<mRegion>
<wRegion>P</wRegion>
</mRegion>
</Config>
I can update, delete and add a single child node to a section but I haven't been able to create the whole file from scratch if the program cannot find the file on start up?
Thanks in advance.
XElement xml = new XElement("Config",
new XElement("wStatus", ""),
new XElement("wStatus", "1"),
new XElement("wStatus", "2"),
new XElement("wStatus", "3"),
new XElement("wCode", ""),
new XElement("wCode", "AAAA"),
new XElement("wCode", "BBBB"),
new XElement("wCode", "CCCC"),
new XElement("wRegion", "A")
);
xml.Save(Application.StartupPath + "\\config.xml");
I would like to update this code so I can put parent tags around each different set of data so a revised version of the above would look like the following:
<?xml version="1.0" encoding="utf-8"?>
<Config>
<mStatus>
<wStatus>1</wStatus>
<wStatus>2</wStatus>
<wStatus>3</wStatus>
</mStatus>
<mCode>
<wCode>AAAA</wCode>
<wCode>BBBB</wCode>
<wCode>CCCC</wCode>
</mCode>
<mRegion>
<wRegion>P</wRegion>
</mRegion>
</Config>
I can update, delete and add a single child node to a section but I haven't been able to create the whole file from scratch if the program cannot find the file on start up?
Thanks in advance.