1

I have to convert XML data to SQLite then run some query on that SQLite Data and convert the query results back to XML. Do we have any C++ library for this. I am using Linux Operating System.

Regards, Dinesh.

Dinesh P.R.
  • 6,936
  • 6
  • 35
  • 44
  • http://stackoverflow.com/questions/9387610/what-xml-parser-should-i-use-in-c http://stackoverflow.com/questions/120295/what-is-a-good-oo-c-wrapper-for-sqlite – ev-br Jul 07 '12 at 11:42

2 Answers2

2

I'm not aware of one library doing all that, and if so it would be horribly complicated. I'm pretty sure you'll need to use two different libraries: One to do the XML parsing/writing and another to do the SQL transactions. You'd have a better design this way - separation of concerns.

libxml and libsqlite are two examples which are probably quickly installable in your current distribution. e.g. sudo apt-get install libsqlite3-dev libxml2-dev

Then you'll probably want to:

  1. Open the xml, parse into C++ objects and store in a container e.g. std::vector, close the xml.
  2. Open a new sqlite database, create a table maybe more, iterate your C++ container of objects inserting values into the table as you iterate;
  3. Execute a select query on the new table and read the resultset, for each result storing/editing C++ objects;
  4. Create a new xml root object, iterate the new/modified C++ objects and for each object add a new xml node to the root, write the xml tree to a new file.

Hope this helps.

acraig5075
  • 10,588
  • 3
  • 31
  • 50
1

Have you tried libxml++? http://developer.gnome.org/libxml++-tutorial/stable/

user1202136
  • 11,171
  • 4
  • 41
  • 62