Error while writing a Google CCS server in node using node-xmpp

This is python code in Google documentation of writing a CCS server:

https://developer.android.com/google/gcm/gs.html#server

I figured out most of it, and how to code it in Javascript using https://github.com/astro/node-xmpp

But I'm failing to understand how to send data using templates, precisely this part of the code:

def send(json_dict):
  template = ("<message><gcm xmlns='google:mobile:data'>{1}</gcm></message>")
  client.send(xmpp.protocol.Message(
      node=template.format(client.Bind.bound[0], json.dumps(json_dict))))

where in node-xmpp, a send is done by this:

var cl = new xmpp.Client({ jid: username,
                           password: password });
cl.addListener('online',
               function() {
                   argv.slice(5).forEach(
                       function(to) {
                           cl.send(new xmpp.Element('message',
                                                    { to: to,
                                                      type: 'chat'}).
                                   c('body').
                                   t(argv[4]));
                       });

I understand the JSON being sent, But I'm not able to do the binding of the template that they are managing in Python. Any help?

The important part is to send the message in the required format :

<message id="">
  <gcm xmlns="google:mobile:data">
  {
      "to":"REGISTRATION_ID",  // "to" replaces "registration_ids"
      "message_id":"m-1366082849205" // new required field
      "data":
      {
          "hello":"world",
      }
      "time_to_live":"600",
      "delay_while_idle": true/false
  }
  </gcm>
</message>

It doesn't matter if you use a template or not. I don't know python nor javascript, but the purpose of the template in the python example seems to be simply to avoid the need to write the xml tags that wrap the JSON every time you send a message. You can append them to the JSON when you send the message.