public void characters(char buf[], int offset, int len) throws SAXException {
   String str = new String(buf, offset, len);
   if (str != null && !str.trim().equals("")) {
     if (element.compareToIgnoreCase("basic") == 0) {
       basicTag.setValue(str);
     }
     if (element.compareToIgnoreCase("contact") == 0) {
       contactTag.setContact(str);
     }
     if (element.compareToIgnoreCase("note") == 0) {
       noteTag.setNote(str);
     }
   }
 }
 public void startElement(
     String namespaceURI,
     String lName, // local name
     String qName, // qualified name
     Attributes attrs)
     throws SAXException {
   element = qName;
   if (element.compareToIgnoreCase("presence") == 0) {
     presenceTag = new PresenceTag();
     String entity = attrs.getValue("entity").trim();
     presenceTag.setEntity(entity);
   }
   if (element.compareToIgnoreCase("presentity") == 0) {
     presentityTag = new PresentityTag();
     String id = attrs.getValue("id").trim();
     presentityTag.setId(id);
   }
   if (element.compareToIgnoreCase("tuple") == 0) {
     tupleTag = new TupleTag();
     String id = attrs.getValue("id").trim();
     tupleTag.setId(id);
   }
   if (element.compareToIgnoreCase("status") == 0) {
     statusTag = new StatusTag();
   }
   if (element.compareToIgnoreCase("basic") == 0) {
     basicTag = new BasicTag();
   }
   if (element.compareToIgnoreCase("contact") == 0) {
     contactTag = new ContactTag();
     String priority = attrs.getValue("priority").trim();
     if (priority != null) {
       try {
         contactTag.setPriority(Float.parseFloat(priority));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   if (element.compareToIgnoreCase("note") == 0) {
     noteTag = new NoteTag();
   }
 }