numrows(); $domxml = new DOMDocument('1.0', 'utf-8'); $root = $domxml->appendChild($domxml->createElement('rows')); $root->setAttribute('total-rows', $totalRows); $row_count = 1; while($line = $rs->fetchRow()) { $row = $root->appendChild($domxml->createElement('row')); foreach ($line as $col_key => $col_val) { $col = $row->appendChild($domxml->createElement('column')); $col->setAttribute('name', strtolower($col_key)); $col->appendChild($domxml->createTextNode($col_val)); } $row_count++; } $domxml->formatOutput = true; $xml = $domxml->saveXML(); $domxml = null; if ($moveFirst) { $rs->MoveFirst(); } return $xml; } ?>