I have some XML in a string
in memory exactly like this:
EURCHF
EURGBP
public DataTable XMLToDataTable(string YourFilePath)
{
DataTable table = new DataTable("XMLTABLE");
try
{
#region "'< <> >& NOT VALID EXTENSTION IN XML
var xmlContent = File.ReadAllText(YourFilePath);
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(xmlContent.Replace("'", "'").Replace("&", "&"));
xDoc.Save(YourFilePath);
#endregion
//All XML Document Content
//XmlElement root = xDoc.DocumentElement;
string RootNode = xDoc.DocumentElement.Name;
string RootChildNode = xDoc.DocumentElement.LastChild.Name;
DataSet lstNode = new DataSet();
lstNode.ReadXml(YourFilePath);
table = lstNode.Tables[RootChildNode];
return table;
}
catch (Exception ex)
{
}
}