Javatpoint Logo
Javatpoint Logo

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



Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials