none
.NET xml 大文件如何快速转换成 DataTable?或者.... RRS feed

  • 问题

  • 有几万行数据的xml,如何快速转换成 DataTable .

    或者将 xml 直接插入到 Sql Server 中,xml字段名和数据库字段名不一样

    2013年8月23日 3:37

答案

  • DataTable ReadXml 如何?

    2013年8月23日 3:45
  • DataTable ReadXml 如何?

    补充:

    正解,不过必须要符合DataTable的格式,否则会读取错误。

    建议随便弄一个DataTable填充数据,然后WriteToXml观察格式,修改原先的xml即可。


    If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer

    Help by clicking:
    Click here to donate your rice to the poor
    Click to Donate
    Click to feed Dogs & Cats


    Found any spamming-senders? Please report at: Spam Report

    2013年8月23日 6:47
    版主
  • 几万行的数据也不算是非常大吧,你可以尝试一下Linq to Xml,或者XmlSerializer读取其中的数据到内存之后转换成DataTable,或者像DroidXgnaW所说的,使用DataTable.ReadXml,然后比较一下处理速度,选择最优方案。

    Caillen
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年8月26日 1:55
    版主

全部回复

  • DataTable ReadXml 如何?

    2013年8月23日 3:45
  • DataTable ReadXml 如何?

    补充:

    正解,不过必须要符合DataTable的格式,否则会读取错误。

    建议随便弄一个DataTable填充数据,然后WriteToXml观察格式,修改原先的xml即可。


    If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer

    Help by clicking:
    Click here to donate your rice to the poor
    Click to Donate
    Click to feed Dogs & Cats


    Found any spamming-senders? Please report at: Spam Report

    2013年8月23日 6:47
    版主
  • 几万行的数据也不算是非常大吧,你可以尝试一下Linq to Xml,或者XmlSerializer读取其中的数据到内存之后转换成DataTable,或者像DroidXgnaW所说的,使用DataTable.ReadXml,然后比较一下处理速度,选择最优方案。

    Caillen
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年8月26日 1:55
    版主