Created
June 28, 2018 09:52
-
-
Save ssaurel/c1e392eab968850d0414e17c54fa05b6 to your computer and use it in GitHub Desktop.
Preparing the XML Parser for the SSaurel's Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ssaurel.xmlparsing; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.TextView; | |
import org.xmlpull.v1.XmlPullParser; | |
import org.xmlpull.v1.XmlPullParserException; | |
import org.xmlpull.v1.XmlPullParserFactory; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.util.ArrayList; | |
public class MainActivity extends AppCompatActivity { | |
private TextView txt; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
txt = (TextView) findViewById(R.id.txt); | |
parseXML(); | |
} | |
private void parseXML() { | |
XmlPullParserFactory parserFactory; | |
try { | |
parserFactory = XmlPullParserFactory.newInstance(); | |
XmlPullParser parser = parserFactory.newPullParser(); | |
InputStream is = getAssets().open("data.xml"); | |
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); | |
parser.setInput(is, null); | |
processParsing(parser); | |
} catch (XmlPullParserException e) { | |
} catch (IOException e) { | |
} | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment