powered by Jive Software

Custom extension format with smack 4.1.8 StanzaListener

We define a custom xmpp message format like this " app nameabc<app_version>1</app_version>.
I can see the complete xmpp response message from Smack Debug Log, but when I try to parse <app_version>1</app_version> custom extension via stanzalistener, I can only obtain element name, but I was not able to get the value of 1.

I found some discuss from forum or stackoverflow, the custom element should be define as

  1. β€œ<app_version>1</app_version>” --> get value from element.toXML and parse it
  2. "<app_version xmlns=β€˜app_version:version’ value=β€˜1’/> --> get value from attribute

when I change the format to above two format then I can get what I want
my question will be: is other way to get the value without change the custom extension format?

I would highly suggest you to use the format of 2, as it makes most sense.


The complete response message will be like above:

  1. Is it right way to parsing the response via StanzaListener?
  2. Does my xmpp message follow standard?

There is no parsing done in the StanzaListeners. It happens before and is performed by Provider.

No, extension elements need to be qualified by a (unique) namespace. I’d also group them in a single extension element.

You probably want something like

<message to='jid' ... >
    <myelement xmlns='my:extension:namespace:0'>


<message to='jid' ... >
    <myelement xmlns='my:extension:namespace:0' number='2' total='3' thread='session_id' app_version='1'/>
1 Like

Thank you for your help.