Reputation: 263
I have generated an XML file by exporting my SQLite database in c#.net.My generated XML is like-
<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. I need to verify the contents before inserting into SQLite database. I have created an XSD file from my existing XML file.i used NDbUnit library here. My codes for importing the data from the XML into SQLite database are following -
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. the problem is sqlite manager does not support exporting database to XSD file. Moreover, i can't find any clear documentation for crating the XSD using NDbUnit. Could anyone help please ?
Upvotes: 0
Views: 2781
Reputation: 11717
The NDbUnit framework does exactly what you need. So no need to get your hands dirty. Also available via NuGet.
Upvotes: 1