I have the data in the list as below.
List<APIConfigValue>
Now I have to generate the XML file as below.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ScanTime.Web" value="11D_SVC1" />
<add key="eTime.Punch" value="true" />
<add key="DataMartUrl" value="syscontrol" />
</appSettings>
</configuration>
Based on the no of records in the list, it should automatically generate. I am trying using xml linq libraries.
This is how i started...
XDocument doc = new XDocument(
new XElement("configuration",
new XElement("appSettings",
new XElement("add", new XAttribute("key", "APP.Web"), new XAttribute("value", "true"))
)
)
);
I got stuck on how to loop through from the list here. I tried to find articles. But nothing close. Appreciate your time and Responses.