Javatpoint Logo
Javatpoint Logo

Android XML Parsing using DOM Parser

We can parse the xml document by dom parser also. It can be used to create and parse the xml file.

Advantage of DOM Parser over SAX

It can be used to create and parse the xml file both but SAX parser can only be used to parse the xml file.

Disadvantage of DOM Parser over SAX

It consumes more memory than SAX.


Example of android DOM 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

Let's write the code to parse the xml using dom parser.

File: MainActivity.java


Output:

DOM Xml Parsing




Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA