Friday, May 30, 2014

Importing data from an XML file to an SQLite Database: ContactBook Example Program Code [XML][SQLite][Java]


I thought of making a program that imports some "Contact" data from an XML file specified by the user into an existing (or newly created) SQLite database.

The application first imports the data and then asks the user to choose an operation to perform on the resulting database ContactBook. The code is somewhat long so I've posted it on pastebin.com

Here's the link : Source Code

The XML file that I used to test it:

<Contacts>
 <Contact>
  <Name>Peter Parker</Name>
  <Age>25</Age>
  <Address>123 SomeStreet, Some City</Address>
  <PhoneNo>123-222-1234</PhoneNo>
 </Contact>

 <Contact>
  <Name>Harry Potter</Name>
  <Age>21</Age>
  <Address>123 SomeStreet, Some City</Address>
  <PhoneNo>123-123-2345</PhoneNo>
 </Contact>


 <Contact>
  <Name>Dude</Name>
  <Age>48</Age>
  <Address>123 SomeStreet, Some City</Address>
  <PhoneNo>152-323-5555</PhoneNo>
 </Contact>

<Contact>
  <Name>Duplicate Dude</Name>
  <Age>48</Age>
  <Address>123 SomeStreet, Some City</Address>
  <PhoneNo>152-323-5555</PhoneNo>
 </Contact>
</Contacts>

Duplicates are found based on Equal Phone Numbers and are skipped.


No comments:

Post a Comment