venkat

venkat

  • NA
  • 138
  • 51.7k

convert List<List<>> to XML in c#

Aug 3 2018 6:18 AM
Hi All,
 
I have List of List and need to convert as xmlelement please any one help.
 
I have Tried like this. Below is my code.
 
insertDetails.BulkrefTableList is the List of List data. (i mean. List<List<Classname>> )
 
foreach (var RefData in insertDetails.BulkrefTableList)
{
XDocument RefDataDetails = new XDocument(new XDeclaration("1.0", "UTF - 8", "yes"),
new XElement(insertDetails.TableName,
from RefDetails in RefData
select new XElement(insertDetails.TableName,
new XElement("ColumnNames", RefDetails.ColumnNames),
new XElement("ColumnValues", RefDetails.ColumnValues),
new XElement("IsPrimary", RefDetails.IsPrimary.ToString()))));
}
 

Answers (4)