function parse (options, document, callback) {
  xml2js.parseString(document, {
    trim: true,
    normalizeTags: true,
    normalize: true
  }, function (err, result) {
    var source = options.source;

    if (!err) {

      // Process the url input, but break if base.input returns false.
      //   In other words, _.find is looking for a non-falsy err.
      // For now, this can only happen if no outputDir is defined,
      //   which is a fatal bad option problem and will happen immediately.
      _.find(
        // if the sitemap is malformed, just blow up
        result.urlset.url,
        function (urlNode) {
          // optionally ignore current urls by sitemap policy
          var url,
              process = !options.sitemapPolicy ||
                !stillCurrent(urlNode, options);

          if (process) {
            // if sitemap is malformed, just blow up
            url = urlm.parse(urlNode.loc[0]);
            if (!base.input(_.extend({}, options, {
                protocol: url.protocol,
                auth: url.auth,
                hostname: url.hostname,
                port: url.port
              }),
              urlNode.loc[0])
            ) {
              source = urlNode.loc[0];
              err = base.generatorError();
            }
          }

          return err;
        }
      );
    }

    callback(common.prependMsgToErr(err, source, true));
  });
}
function parse (options, document, callback) {
  xml2js.parseString(document, {
    trim: true,
    normalizeTags: true,
    normalize: true
  }, function (err, result) {
    var source = options.source;

    if (!err) {

      
      
      
      
      _.find(
        
        result.urlset.url,
        function (urlNode) {
          
          var url,
              process = !options.sitemapPolicy ||
                !stillCurrent(urlNode, options);

          if (process) {
            
            url = urlm.parse(urlNode.loc[0]);
            if (!base.input(_.extend({}, options, {
                protocol: url.protocol,
                auth: url.auth,
                hostname: url.hostname,
                port: url.port
              }),
              urlNode.loc[0])
            ) {
              source = urlNode.loc[0];
              err = base.generatorError();
            }
          }

          return err;
        }
      );
    }

    callback(common.prependMsgToErr(err, source, true));
  });
}
function parse ( options , document , callback ) { xml2js . parseString ( document , { trim : true , normalizeTags : true , normalize : true } , function ( err , result ) { var source = options . source ; if ( ! err ) { // Process the url input, but break if base.input returns false. //   In other words, _.find is looking for a non-falsy err. // For now, this can only happen if no outputDir is defined, //   which is a fatal bad option problem and will happen immediately. _ . find ( // if the sitemap is malformed, just blow up result . urlset . url , function ( urlNode ) { // optionally ignore current urls by sitemap policy var url , process = ! options . sitemapPolicy || ! stillCurrent ( urlNode , options ) ; if ( process ) { // if sitemap is malformed, just blow up url = urlm . parse ( urlNode . loc [ 0 ] ) ; if ( ! base . input ( _ . extend ( { } , options , { protocol : url . protocol , auth : url . auth , hostname : url . hostname , port : url . port } ) , urlNode . loc [ 0 ] ) ) { source = urlNode . loc [ 0 ] ; err = base . generatorError ( ) ; } } return err ; } ) ; } callback ( common . prependMsgToErr ( err , source , true ) ) ; } ) ; }
Parse a sitemap document
For each qualifying url element in urlset, call base.input
Stops processing if an error occurs.

@param {Object} options - Sitemap options.
@param {String} options.source - The sitemap url or file.
@param {Boolean} options.sitemapPolicy - True if sitemapPolicy should be enforced.
@param {String} document - An xml document string.
@param {Function} callback - The completion callback.
Parse a sitemap document For each qualifying url element in urlset call base . input Stops processing if an error occurs .