code: function(features, metadata) {
          features = OpenLayers.Util.isArray(features) ?
              features : [features];
          var gpx = this.createElementNS(this.namespaces.gpx, "gpx");
          gpx.setAttribute("version", "1.1");
          gpx.setAttribute("creator", this.creator);
          this.setAttributes(gpx, {
              "xsi:schemaLocation": this.schemaLocation
          });
  
          if (metadata && typeof metadata == 'object') {
              gpx.appendChild(this.buildMetadataNode(metadata));
          }
          for(var i=0, len=features.length; i<len; i++) {
              gpx.appendChild(this.buildFeatureNode(features[i]));
          }
          return OpenLayers.Format.XML.prototype.write.apply(this, [gpx]);
      }
docs: APIMethod: write
  Accepts Feature Collection, and returns a string.
  
  Parameters:
  features - {Array(<OpenLayers.Feature.Vector>)} List of features to serialize into a string.
  metadata - {Object} A key/value pairs object to build a metadata node to
  add to the gpx. Supported keys are 'name', 'desc', 'author'.