TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
unathi guma
NA
40
9.8k
Generating the DataTable from the XML file
Feb 26 2019 7:31 AM
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<string> Valores = Fila.ChildNodes.Cast().ToList().Select(x => x.InnerText).ToList();
Dt.Rows.Add(Valores.ToArray());
Progress();
}
}
catch (Exception ex)
{
}
return Dt;
}
Reply
Answers (
9
)
How to align data fields next to detail section
Why is this error occurring