function ResultSet() {

  resultSet = new Array();
  len = -1;
  currentIndex = -1;
  queryTime = null;
  erro = null;

  // Monta o ResultSet com base nos dados recebidos
  this.mount = function(resp,rootNode) {
  	
    var response = null;

    if (resp.getElementsByTagName(rootNode)[0]) response = resp.getElementsByTagName(rootNode)[0];

    if (response != null) {

      if (response.getAttribute('queryTime') != null && response.getAttribute('queryTime') != '')
        queryTime = response.getAttribute('queryTime');

      if (response.firstChild) {
          
        len = response.firstChild.childNodes.length;

        if (len < 1)  {
          erro = 'Estrutura do arquivo XML inválida. Nenhuma linha encontrada.';
          return false;
        }
          
        var lines = new Array();

        for (var i = 0; i < response.firstChild.childNodes.length; i++) {

          if (response.firstChild.childNodes[i].childNodes.length < 1)  {
            erro = 'Estrutura do arquivo XML inválida. Nenhuma coluna encontrada no registro ' + i + ' do documento.';
            return false;
          }

          var fields = new Array();
          var wf = new WebFormat();
            
          for (var j = 0; j < response.firstChild.childNodes[i].childNodes.length; j++) {
            fields[j] = wf.decodeUTF8(response.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue);
          }
          
          wf = null;
          lines[i] = fields;
            
        }
          
        resultSet = lines;
        return true; 
          
      }
          
    } else {
        
      if (resp.getElementsByTagName('no-response')[0]) {

        response = resp.getElementsByTagName('no-response')[0];
        
        if (response.getAttribute('queryTime') != '' && response.getAttribute('queryTime') != null)
          queryTime = response.getAttribute('queryTime');
            
        len = 0;
        return true;

      } else {
          
        erro = 'A resposta é nula';
        return false;
          
      }
        
    }
    
  }

  // Vai para a próxima linha do resultado
  this.next = function() {
      
    if (resultSet.length > 0) {
      try {
        if (resultSet[currentIndex+1][0]) {
          currentIndex++;
          return true;
        }
      } catch (e) {
        return false;
      }
    }   
    return false;
    
  }

  // Retorna o valor de um campo na linha corrente
  this.getValue = function(column) {
      
    if (resultSet[currentIndex][column]) return resultSet[currentIndex][column]; 
    else return null;
      
  }

  // Vai para a linha indicada começando de zero
  this.goTo = function(line) {
      
    if (resultSet[line][0]) {
      currentIndex = line;
      return true;
    }
      
    return false; 
      
  }
 
  // Retorna um erro quando houver
  this.getErro = function() {
      
    if (erro != null) return erro;
    else return null;
      
  }

  // Retorna o tempo da pesquisa do XML
  this.getQueryTime = function() {
  	
    return queryTime;
    
  }

  // Destroi as propriedades do objeto ResultSet
  this.close = function(line) {

    resultSet = null;
    len = null;
    currentIndex = null;
    queryTime = null;
    erro = null;
      
  }

}

