lib/middleware/lrdd.js
function serializeToXRD(descriptor) {
  var xml = '<?xml version="1.0" encoding="UTF-8"?>';
  xml += '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';

  if (descriptor.expires) {
    xml += '<Expires>' + xsdDateTimeString(descriptor.expires) + '</Expires>';
  }

  if (descriptor.subject) {
    xml += '<Subject>' + descriptor.subject + '</Subject>';
  }

  descriptor.aliases.forEach(function(alias) {
    xml += '<Alias>' + alias + '</Alias>';
  });

  descriptor.properties.forEach(function(key, value) {
    if (value) {
      xml += '<Property type="' + key + '">' + value + '</Property>';
    } else {
      xml += '<Property type="' + key + '" xsi:nil="true" />';
    }
  });

  descriptor.links.forEach(function(link) {
    xml += '<Link';
    if (link.rel) { xml += ' rel="' + link.rel + '"'; }
    if (link.href) { xml += ' href="' + link.href + '"'; }
    if (link.template) { xml += ' template="' + link.template + '"'; }
    if (link.type) { xml += ' type="' + link.type + '"'; }
    xml += '>';
  
    link.titles.forEach(function(lang, title) {
      if (lang === '_') {
        xml += '<Title>' + title + '</Title>';
      } else {
        xml += '<Title xml:lang="' + lang + '">' + title + '</Title>';
      }
    });
  
    link.properties.forEach(function(key, value) {
      if (value) {
        xml += '<Property type="' + key + '">' + value + '</Property>';
      } else {
        xml += '<Property type="' + key + '" xsi:nil="true" />';
      }
    });
  
    xml += '</Link>';
  });

  xml += '</XRD>';

  return xml;
}
function serializeToXRD(descriptor) {
  var xml = '<?xml version="1.0" encoding="UTF-8"?>';
  xml += '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';

  if (descriptor.expires) {
    xml += '<Expires>' + xsdDateTimeString(descriptor.expires) + '</Expires>';
  }

  if (descriptor.subject) {
    xml += '<Subject>' + descriptor.subject + '</Subject>';
  }

  descriptor.aliases.forEach(function(alias) {
    xml += '<Alias>' + alias + '</Alias>';
  });

  descriptor.properties.forEach(function(key, value) {
    if (value) {
      xml += '<Property type="' + key + '">' + value + '</Property>';
    } else {
      xml += '<Property type="' + key + '" xsi:nil="true" />';
    }
  });

  descriptor.links.forEach(function(link) {
    xml += '<Link';
    if (link.rel) { xml += ' rel="' + link.rel + '"'; }
    if (link.href) { xml += ' href="' + link.href + '"'; }
    if (link.template) { xml += ' template="' + link.template + '"'; }
    if (link.type) { xml += ' type="' + link.type + '"'; }
    xml += '>';
  
    link.titles.forEach(function(lang, title) {
      if (lang === '_') {
        xml += '<Title>' + title + '</Title>';
      } else {
        xml += '<Title xml:lang="' + lang + '">' + title + '</Title>';
      }
    });
  
    link.properties.forEach(function(key, value) {
      if (value) {
        xml += '<Property type="' + key + '">' + value + '</Property>';
      } else {
        xml += '<Property type="' + key + '" xsi:nil="true" />';
      }
    });
  
    xml += '</Link>';
  });

  xml += '</XRD>';

  return xml;
}
function serializeToXRD ( descriptor ) { var xml = '<?xml version="1.0" encoding="UTF-8"?>' ; xml += '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ; if ( descriptor . expires ) { xml += '<Expires>' + xsdDateTimeString ( descriptor . expires ) + '</Expires>' ; } if ( descriptor . subject ) { xml += '<Subject>' + descriptor . subject + '</Subject>' ; } descriptor . aliases . forEach ( function ( alias ) { xml += '<Alias>' + alias + '</Alias>' ; } ) ; descriptor . properties . forEach ( function ( key , value ) { if ( value ) { xml += '<Property type="' + key + '">' + value + '</Property>' ; } else { xml += '<Property type="' + key + '" xsi:nil="true" />' ; } } ) ; descriptor . links . forEach ( function ( link ) { xml += '<Link' ; if ( link . rel ) { xml += ' rel="' + link . rel + '"' ; } if ( link . href ) { xml += ' href="' + link . href + '"' ; } if ( link . template ) { xml += ' template="' + link . template + '"' ; } if ( link . type ) { xml += ' type="' + link . type + '"' ; } xml += '>' ; link . titles . forEach ( function ( lang , title ) { if ( lang === '_' ) { xml += '<Title>' + title + '</Title>' ; } else { xml += '<Title xml:lang="' + lang + '">' + title + '</Title>' ; } } ) ; link . properties . forEach ( function ( key , value ) { if ( value ) { xml += '<Property type="' + key + '">' + value + '</Property>' ; } else { xml += '<Property type="' + key + '" xsi:nil="true" />' ; } } ) ; xml += '</Link>' ; } ) ; xml += '</XRD>' ; return xml ; }
Serialize `descriptor` to XRD format.

@param {Descriptor} descriptor
@return {String}
@api private
Serialize descriptor to XRD format .