Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new xml file

  • Thread starter Thread starter member 472187
  • Start date Start date
Status
Not open for further replies.
M

member 472187

Guest
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top