91-9990449935 0120-4256464 |
Android XML Parsing using DOM ParserWe 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 SAXIt 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 SAXIt consumes more memory than SAX. Example of android DOM Xml parsingactivity_main.xmlDrag the one textview from the pallete. Now the activity_main.xml file will look like this: File: activity_main.xml
xml documentCreate an xml file named file.xml inside the assets directory of your project. File: file.xml
Activity classLet's write the code to parse the xml using dom parser. File: MainActivity.java
Output:
Next TopicAndroid XMLPullParser Tutorial
|