Android XML parsing with complex data

i know this might be a simple question of parsing an xml in android

here what my response is..

<Output>
<category>
  <maincategory id="196">300mm x 300mm (12" x 12")</maincategory>
    <subcategory>
      <category id="206">Anti Skid Sp. Color Series</category>
      <category id="199">Ivory Matt Series</category>
   </subcategory>
</category>
<category>
 <maincategory id="195">395mm x 395mm (16" x 16")</maincategory>
  <subcategory>
   <category id="198">Cloudy Series</category>
   <category id="197">Plain Color Series</category>
 </subcategory>
 </category>
</Output>

can i anyone provide a link for this type of parsing. i want id and name of the category from this response.

i have already tried this: 1)http://theopentutorials.com/tutorials/android/xml/android-simple-xmlpullparser-tutorial/ and 2)xml parse example 3)http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/

Thanks in Advance. Answer will be appreciated

Answer

Try with a dom parser, here’s an example: http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser