how to add element in XML Message using Stophe

56 Views Asked by At

I am using Strophe JS

I want to add element inside the message xml tag.

The Strophe Link : http://strophe.im/strophejs/doc/1.1.3/files/strophe-js.html

My code is :

connection.sendIQ($iq({type: "get"}).c("query", {xmlns: Strophe.NS.ROSTER}).tree(), onRoster);
connection.send(
                $msg(
                      {
                        to:"[email protected]/primea",
                        id:"user2_1564828681632",
                        from:"[email protected]/primea",
                      }
                   )

                );

This generates the following XML :

<message from="[email protected]/primea" id="user2_1564828681632" to="[email protected]/primea" xmlns="jabber:client"/>

I need something like this :

<message xmlns:cli="jabber:client" to="[email protected]" cli:subject="TEXT MESSAGE" cli:lang="en" type="chat" id="rajan_1564637142811" from="[email protected]/primea"><body>Some XMPP Message</body><request xmlns="urn:xmpp:receipts"></request></message>

In above XML it has <body> tag inside the <message> tag. How do i do this ? I want to do thing using Stophe JS. To Send XMPP message.

0

There are 0 best solutions below