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;
}
Riddhi ValechaPosted Jan 2, 2020, 3:01 AM
Hello Team,
Same issue -
GetTableName(XmlFile); - Is not there.
Instead of xmlfile, can we put xmlstring ?
Laxmidhar SahooPosted Jan 1, 2020, 10:50 PM
Riddhi ValechaPosted Jan 1, 2020, 12:23 PM
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
Rajanikant HawaldarPosted Dec 28, 2019, 4:47 AM
Laxmidhar SahooPosted Dec 25, 2019, 1:42 AM
Vivek KumarPosted Feb 27, 2019, 3:44 PM
Salman BegPosted Feb 26, 2019, 8:32 AM
Amit GuptaPosted Feb 26, 2019, 7:44 AM
unathi gumaPosted Feb 26, 2019, 7:36 AM