views:

45

answers:

1
+2  A: 

When you encounter a starting tag matching "student", set some boolean variable (called insideStudent for example) to true. Similarly, when you encounter a "degree" tag set another insideDegree variable to true. When you have a closing tag, set them to false (e.g. if you have </student> then you set insideStudent to false). Now when you encounter an ID tag, you just need to check if you're only inside student or inside both of degree and student. Something like:

if(tag_name.equalsIgnoreCase("ID")){
    // Get student ID
    if (insideStudent && !insideDegree) {
          stud_id = parser.nextText().toString();
          Log.i("Id = ", pid);
    }
} 
Firas Assaad
@Firas sorry for late reply about your answer, and i have already done this way, i declared integer variables making them 0 and 1 on starting/closing tag. Thanks for the support
PM - Paresh Mayani