code: function (name)
      {
          if (!name) { return null; }
  
          var node = Strophe.xmlGenerator().createElement(name);
  
          // FIXME: this should throw errors if args are the wrong type or
          // there are more than two optional args
          var a, i, k;
          for (a = 1; a < arguments.length; a++) {
              if (!arguments[a]) { continue; }
              if (typeof(arguments[a]) == "string" ||
                  typeof(arguments[a]) == "number") {
                  node.appendChild(Strophe.xmlTextNode(arguments[a]));
              } else if (typeof(arguments[a]) == "object" &&
                         typeof(arguments[a].sort) == "function") {
                  for (i = 0; i < arguments[a].length; i++) {
                      if (typeof(arguments[a][i]) == "object" &&
                          typeof(arguments[a][i].sort) == "function") {
                          node.setAttribute(arguments[a][i][0],
                                            arguments[a][i][1]);
                      }
                  }
              } else if (typeof(arguments[a]) == "object") {
                  for (k in arguments[a]) {
                      if (arguments[a].hasOwnProperty(k)) {
                          node.setAttribute(k, arguments[a][k]);
                      }
                  }
              }
          }
  
          return node;
      }
docs: Function: xmlElement
  Create an XML DOM element.
  
  This function creates an XML DOM element correctly across all
  implementations. Note that these are not HTML DOM elements, which
  aren't appropriate for XMPP stanzas.
  
  Parameters:
  (String) name - The name for the element.
  (Array|Object) attrs - An optional array or object containing
  key/value pairs to use as element attributes. The object should
  be in the format {'key': 'value'} or {key: 'value'}. The array
  should have the format [['key1', 'value1'], ['key2', 'value2']].
  (String) text - The text child data for the element.
  
  Returns:
  A new XML DOM element.