Hi SQLEnthusiast007,
We could use XDocument to achieve your requirement. I create a simple demo as below for your reference.
var codes = db.CodeTexts.Select(c => c.Code + "-" + c.Text).ToList();
string result = string.Join(",", codes.ToArray());
string[] arrayList = result.Split(',');
XDocument doc = new XDocument();
XElement root = new XElement("Root");
foreach (var item in arrayList)
{
string[] itemarray = item.Split('-');
XElement elm = new XElement("CodeText",
new XElement("Code", itemarray[0]),
new XElement("Text", itemarray[1]));
root.Add(elm);
}
Best regards,
Cole Wu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.