[英]Import an XML file and insert data into SQLite database in c#
I have generated an XML file by exporting my SQLite database in c#.net.My generated XML is like- 我已经通过在c#.net中导出SQLite数据库生成了XML文件。生成的XML类似于-
<root>
<name1>
<names>
<id>5</id>
<from>Germany</from>
<to>France</to>
<through>
<via>
<id>7</id>
<routeNo>5<routeNo>
<route>Vienna<route>
</via>
</through>
</names>
<names>
<id>10</id>
<from>US</from>
<to>Canada</to>
<through>
<via>
<id>8</id>
<routeNo>10<routeNo>
<route>Mexico<route>
</via>
</through>
</names>
</name1>
</root>
I am trying to import this XML file and insert all the data back into an empty SQLite database. 我正在尝试导入此XML文件,并将所有数据重新插入到空的SQLite数据库中。 I need to verify the contents before inserting into SQLite database. 在插入SQLite数据库之前,我需要验证内容。 I have created an XSD file from my existing XML file.i used NDbUnit library here. 我已经从现有的XML文件创建了一个XSD文件。我在这里使用了NDbUnit库。 My codes for importing the data from the XML into SQLite database are following - 我将代码从XML导入SQLite数据库的代码如下-
string connectionString = "Data Source=emptyDB.sqlite;Version=3;New=True;Compress=True;";
NDbUnit.Core.INDbUnitTest Database = new NDbUnit.Core.SqlClient.SqlDbUnitTest(connectionString);
Database.ReadXmlSchema("myFlatXml.xsd");
Database.ReadXml("myFlatXml.xml");
Database.PerformDbOperation(NDbUnit.Core.DbOperationFlag.CleanInsertIdentity);
I have used XSD file which is generated from XML file, but it seems, I have to create the XSD from my sqlite database. 我使用了从XML文件生成的XSD文件,但是看来,我必须从我的sqlite数据库创建XSD。 the problem is sqlite manager does not support exporting database to XSD file. 问题是sqlite管理器不支持将数据库导出到XSD文件。 Moreover, i can't find any clear documentation for crating the XSD using NDbUnit. 而且,我找不到使用NDbUnit创建XSD的任何清晰文档。 Could anyone help please ? 有人可以帮忙吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.