I have this below XML string , got it from SqlDependency
that monitor sql table
,I want to Convert it to List or datatable
<root>
<inserted>
<row>
<invoice_id>26</invoice_id>
<invoice_type>5</invoice_type>
<client_id>372</client_id>
<create_date>2019-12-02T13:49:21.430</create_date>
<status_id>1</status_id>
<sales_rep_id>1</sales_rep_id>
<courrier_id>12</courrier_id>
<items_quantity>3</items_quantity>
<sub_total>0.00</sub_total>
<discount>0.00</discount>
<shipping>0.00</shipping>
<tax>0.00</tax>
<grand_total>0.00</grand_total>
<prepared_by>11</prepared_by>
<current_state>PREPARED</current_state>
<store_ID>1</store_ID>
<extra></extra>
<user_id>11</user_id>
<open_date>2019-12-02T13:52:53.583</open_date>
<prepared_date>2019-12-02T13:54:10.877</prepared_date>
<preparing_notes></preparing_notes>
<to_courier_date>2019-12-02T14:34:17.953</to_courier_date>
</row>
</inserted>
</root>
I tried the below code :
string xml = ee.Data.ToString();// XML string above
List<string> Lst = new List<string>();
XmlReader xr = XmlReader.Create(new StringReader(xml));
var xMembers = from members in XElement.Load(xr).Elements() select members;
foreach (XElement x in ee.Data.Elements("root"))
{
Lst.Add ( x.Value);
}
but not working also tired for converting it to Datatable
public DataTable XML2DT(string xmlData)
{
StringReader theReader = new StringReader(xmlData);
DataSet theDataSet = new DataSet();
theDataSet.ReadXml(theReader);
return theDataSet.Tables[0];
}
return error , so can anyone help me to convert it to any usable object to store there new data