Home » Android XML Parsing using SAX Parser

Android XML Parsing using SAX Parser

by Online Tutorials Library

Android XML Parsing using SAX Parser

Android provides the facility to parse the xml file using SAX, DOM etc. parsers. The SAX parser cannot be used to create the XML file, It can be used to parse the xml file only.

Advantage of SAX Parser over DOM

It consumes less memory than DOM.


Example of android SAX Xml parsing

activity_main.xml

Drag the one textview from the pallete. Now the activity_main.xml file will look like this:

File: activity_main.xml

xml document

Create an xml file named file.xml inside the assets directory of your project.

File: file.xml

Activity class

Now write the code to parse the xml using sax parser.

File: MainActivity.java


Output:

SAX Xml Parsing

You may also like