Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataTable does not support schema inference from Xml.?

Tags:

c#

xml

datatable

<?xml version="1.0" encoding="utf-8"?> <PHP_Adapter>   <Adapter>     <ID>11</ID>     <Provider>22</Provider>     <Connectstring>33</Connectstring>   </Adapter> </PHP_Adapter> 

This my Xml file what wrong?

    bool CheckAdapterExist(string aid)     {         DataTable dt = new DataTable();         dt.ReadXml(axml);         MessageBox.Show(dt.Rows[0]["ID"].ToString());          return true;     } 
like image 723
monkey_boys Avatar asked Dec 20 '09 11:12

monkey_boys


1 Answers

Try using a Dataset rather

DataSet ds = new DataSet(); ds.ReadXml(@"d:\test.xml"); MessageBox.Show(ds.Tables[0].Rows[0]["ID"].ToString()); 

Found at

DataTable.ReadXml(filename) throws an error. Why?

like image 75
Adriaan Stander Avatar answered Sep 21 '22 08:09

Adriaan Stander