开发者

SQLite query to read an XML file

I want a SQLite query for reading my XML file and then I want a function that will convert my XML file to an SQLite t开发者_如何转开发able.


There's no query or function to do this. The way to go is to write a stylesheet (.xsl) that produces output consumable by sqlite's .import command.


There is no way to read XML using SQLite commands, but you can create your own function which takes an XML path as parameter. Follow these steps, assuming that you are using .NET, and you know the structure of the XML (nodes, elements and attributes):

  1. Load the XML in XmlDocument, so that you can read the XML elements.
  2. Iterate one for loop for number of times equal to the node count in XML.
  3. Build one dynamic string which prepares the insert command in SQLite, with all the required node values as column values.
  4. Execute the dynamically prepared insert command in SQlite.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜