Here is my Parser & IQ
``
public class WhiteboardInvitation extends IQ {
/** The Constant ELEMENT_NAME. */
public static final String ELEMENT_NAME = "invitation";
/** The accept. */
private boolean accept = false;
/**
* Instantiates a new whiteboard invitation.
*/
public WhiteboardInvitation() {
super();
}
/**
* Sets the accept.
*
* @param accept the new accept
*/
public void setAccept(boolean accept) {
this.accept = accept;
}
/**
* Gets the accept.
*
* @return the accept
*/
public boolean getAccept() {
return accept;
}
/* (non-Javadoc)
* @see org.jivesoftware.smack.packet.IQ#getChildElementXML()
*/
public String getChildElementXML() {
StringBuffer buf = new StringBuffer();
buf.append("<" + ELEMENT_NAME + " xmlns=\"" + SVGConstants.NAMESPACE
+ "\">");
if (this.getType() != Type.GET) {
buf.append("<accept>" + String.valueOf(getAccept()) + "</accept>");
}
buf.append(getExtensionsXML());
buf.append("</" + ELEMENT_NAME + ">");
return buf.toString();
}
/**
* The Class Provider.
*/
public static class Provider implements IQProvider {
/**
* Instantiates a new provider.
*/
public Provider() {
super();
}
/* (non-Javadoc)
* @see org.jivesoftware.smack.provider.IQProvider#parseIQ(org.xmlpull.v1.XmlPullParser)
*/
public IQ parseIQ(XmlPullParser parser) throws Exception {
WhiteboardInvitation invite = new WhiteboardInvitation();
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("accept")) {
invite.setAccept(Boolean
.parseBoolean(parser.nextText()));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(ELEMENT_NAME)) {
done = true;
}
}
}
return invite;
}
}
}