I got this code here and it's giving me errors.
public DataTable CreateDataTableXML(string XmlFile)
{
XmlDocument doc = new XmlDocument();
doc.Load(XmlFile);
try
{
Dt.TableName = GetTableName(XmlFile);
XmlNode NodoEstructura = doc.DocumentElement.ChildNodes.Cast.ToList()[0];
progressBar1.Maximum = NodoEstructura.ChildNodes.Count;
progressBar1.Value = 0;
foreach (XmlNode columna in NodoEstructura.ChildNodes)
{
Dt.Columns.Add(columna.Name, typeof(String));
Progress();
}
XmlNode Filas = doc.DocumentElement;
progressBar1.Maximum = Filas.ChildNodes.Count;
progressBar1.Value = 0;
foreach (XmlNode Fila in Filas.ChildNodes)
{
List Valores = Fila.ChildNodes.Cast().ToList().Select(x => x.InnerText).ToList();
Dt.Rows.Add(Valores.ToArray());
Progress();
}
}
catch (Exception ex)
{
}
return Dt;
}

Amit GuptaRank #190 · 12.8K reputationPosted Feb 26, 2019, 2:44 AM EST
Vivek KumarRank #272 · 9.3K reputationPosted Feb 27, 2019, 10:44 AM EST
unathi guma45 reputationPosted Feb 26, 2019, 2:36 AM EST
Salman BegRank #284 · 8.8K reputationPosted Feb 26, 2019, 3:32 AM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 24, 2019, 8:42 PM EST
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Dec 27, 2019, 11:47 PM EST
Riddhi ValechaRank #794 · 2.9K reputationPosted Jan 1, 2020, 7:23 AM EST
I have shared my xml string.
Please help me in converting it into datatable and display it on gridview.
My Post -
https://www.c-sharpcorner.com/Forums/web-api-convert-xml-output-to-datatable-and-display-data
Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 1, 2020, 5:50 PM EST
Riddhi ValechaRank #794 · 2.9K reputationPosted Jan 1, 2020, 10:01 PM EST
Hello Team,
Same issue -
GetTableName(XmlFile); - Is not there.
Instead of xmlfile, can we put xmlstring ?