XML Parsing


 

  1. DOM Parser
  2. XML PullParser
  3. SAX Parser
  4. XML Parsing from Secured Site
  5. Writing a xml file using XMLSerializer

 

1. DOM Parser
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, list_item.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Create android_versoin_list_xml_parsing.xml file, copy paste this code and upload it to the server:

Step 6 : Open src -> package -> Create new class, XMLDOMParser.java and add following code :

Step 7 : Open AndroidManifest.xml and add following code :

ScreenShot:

xml_dom

Download SourceCode

 

2. XML PullParser
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, list_item.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package -> Create new class, XMLPullParserHandler.java and add following code :

Step 6 : Create android_versoin_list_xml_parsing.xml file, copy paste this code and upload it to the server:

Step 7 : Open AndroidManifest.xml and add following code :

ScreenShot:

xml_pull xml_pull2

Download SourceCode

 

3. SAX Parser
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, list_item.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package -> Create new class, .java and add following code :

Step 6 : Create android_versoin_list_xml_parsing.xml file, copy paste this code and upload it to the server:

Step 7 : Open AndroidManifest.xml and add following code :

ScreenShot:

xml_parsing_sax2 xml_parsing_sax

Download SourceCode

 

4. XML Parsing from Secured Site
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, list_item.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package -> Create new class, XMLPullParserHandler.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

ScreenShot:

xml_secured xml_secured2

Download SourceCode

 

5. Writing a xml file using XMLSerializer
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, AndroidVersionHelper.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

xmlwriter xmlwriter2 xmlwriter3

Download SourceCode