Search code examples
xmppsmack

android: how to add attribute to the body ‘s child Element in xmpp


i want to send a message in XMPP just like this:

<message from='86@this' to='861@this' type='chat'>
<body>
 <number id=279
      title='hi'
      word='hello boy'/>
</body>
</message>

Solution

  • modify the Message class toXML() method

    if(defaultBody != null){
          buf.append("<body>);
            if(number != null){
               buf.append("<number").append("id=\"").append(id).append("\"").append("/>");
            }
      }
    

    add like this, I hope it will help you.. thanks..