Articles → .NET → Comma Separated String Using LINQ
Comma Separated String Using LINQ
<root>
<country>India</country>
<country>Sri Lanka</country>
<country>Australia</country>
</root>
DataSet ds = new DataSet();
ds.ReadXml(@"C:\Users\guptak\Desktop\CommaSep\CommaSep\XMLFile1.xml");
string str = string.Join(",", (from element in ds.Tables[0].AsEnumerable() select element["country_text"].ToString()).ToArray());
MessageBox.Show(str);
Click to Enlarge