Skip to content Skip to sidebar Skip to footer

Parse A Local Xml File And Store In Sqlite Database In Android

I would like anybody to show me the CODE on how to read a local xml file (maths.xml) and parse it with a parser and then store the information obtained into a sqllite database (mat

Solution 1:

put your xml file into asset folder and you can get xml in form of input stream

InputStreamraw= context.getApplicationContext().getAssets().open(
                    "maths.xml");

you can parse this xml using different parser like SAX,Dom here is small code of dom parsee

Documentdom= builder.parse(raw);
Elementroot= dom.getDocumentElement()
NodeListmathametician= root.getElementsByTagName("mathametician");

for (int i = 0; i < mathametician.getLength(); i++)

and insert your data to db as you got tag from xml

Post a Comment for "Parse A Local Xml File And Store In Sqlite Database In Android"