xmlr.nextTag(); // move to the first <contact> element.
while (xmlr.getEventType() == START_ELEMENT) {
// unmarshall one <contact> element into a JAXB Contact object
xmlr.require(START_ELEMENT, null, "contact");
Contact contact = (Contact) um.unmarshal(xmlr);
if( contact.getName().equals(nameToLookFor)) {
// we found what we wanted to find. show it and quit now.
System.out.println("the e-mail address is "+contact.getEmail());
return;
}
if (xmlr.getEventType() == CHARACTERS) {
xmlr.next(); // skip the whitespace between <contact>s.
}