powered by Jive Software

How to parse xml correctly in smack

Hi am using smack 4.3.4. I have made one custom xml. When am parsing the incoming custom IQ in success case it working fine.

But when am throwing some error in XML for failure case

<iq type="error" id="LGmcR-64" from="example.com" to="learn@example.com/Miranda">
<query xmlns="com:example:check#request" />
<error code="404" type="cancel">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />

am getting error.

Smack message parsing exception. Content: '<query xmlns='com:example:check#request'></query><error xmlns='jabber:client' code='404' type='cancel'><item-not-found/></error></iq>'

am handling with custom IQ query by:

public class IQUserCustomParamProvider extends IQProvider {
    public CheckQuery parse(XmlPullParser parser, int initialDepth) throws Exception {
        CheckQuery query = new CheckQuery();
        if (parser.getAttributeName(0) != null && parser.getAttributeName(0).equals("status")) {
        if (parser.getAttributeName(1) != null && parser.getAttributeName(1).equals("token")) {

        return query;

I have used one more way

But it throw exception that it can handle iq, presence, message not query

How to parse that error case xml? anybody have Idea how to parse xml in IQProvider extended class?