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
2010-09-11 13:10:23