-3

My app calls a web service and receives a set of data in xml format. How can I populate a database then?

<NewDataSet xmlns="">
          <Country>
            <ID>0001</ID>
            <Type>Country</Type>
            <Code>IN</Code>
            <Description>India</Description>
            <IconName>IN</IconName>
            <IconURL>http://.../IN.jpeg</IconURL>
          </Country>

<Country>
            <ID>0002</ID>
            <Type>Country</Type>
            <Code>FR</Code>
            <Description>France</Description>
            <IconName>FR</IconName>
            <IconURL>http://.../FR.jpeg</IconURL>
          </Country>
</>

Should I store retrieved data as xml file or somehow immediately push it to SQLite?

Ivan Fazaniuk
  • 1,062
  • 3
  • 11
  • 26
  • no, I'm asking where should I store retrieved data before parsing? as an xml file in assets folder? – Ivan Fazaniuk Jun 10 '14 at 17:45
  • The example at jcaruso's link uses an input stream. There is no need to store the XML data in a file. Just parse right away. The for loop iterates through the queried XML elements. – alex Jun 10 '14 at 18:55

1 Answers1

0

Your going to have to parse the XML data and them loop through it to insert it into sqlite.

Try this as for your XML paring: How can I parse xml from url in android?

Then if you have you Content Provider set up call it to do your inserts.

Community
  • 1
  • 1
jcaruso
  • 2,364
  • 1
  • 31
  • 64