Actually, the recordset data is fine. Not mention of XML there. It seems to have to do with this code:
<?php
ob_start();
while (!$query->atEnd()) {
$xml = new SimpleXMLElement('<data/>');
to_xml($xml, $query->Results[$query->Index]);
print $xml->asXML();
$query->moveNext();
}
$output = ob_get_contents();
ob_end_clean();
header('Content-Type: application/xml; charset=utf-8');
header('Content-Language: en');
header('Cache-Control: no-store, no-cache, must-revalidate');
header("Content-Length: ".strlen($output));
header("Date: ".gmdate('D, d M Y H:i:s T'));
echo($output);
?>
It is echo or printing the output or XML twice. When I remove one of them I get the XML data correctly but, I am still having the original issue of the data not repeating all records.