How to read XML into a DataTable?

后端 未结 7 1591
星月不相逢
星月不相逢 2020-12-16 02:51

I have some XML in a string in memory exactly like this:


  EURCHF
  EURGBP

        
相关标签:
7条回答
  • 2020-12-16 03:40

    I've been searching for a easy way to do the same for some time too, but never really found what I actually wanted. Here's one solution I came across. It works, but I don't really like it as I have to Read the File with a DataSet and then put the create Table in the DataSet into a DataTable.

    Anyway's, here's the code:

    DataSet ds = new DataSet();
    ds.ReadXml(path);
    DataTable newDataTable = ds.Tables[0];
    

    I also tried .ReadXml for the DataTable but it always threw an Exception.

    I'm not happy with this solution, but it at least works.

    0 讨论(0)
提交回复
热议问题