class rsUtils
{
	/**
	 * Create a XML chunk from a standard record object.
	 *
	 * @param		record	A standard record object (Cf. Clearbricks dbLayer)
	 * @param		array 	An array of properties to exclude from the dump (default to an empty array)
	 * @return	        string	A string containing the XML chunk.
	 *
	 */
	public static function recordsetToXML($rs,$exclude = array())
	{
		if (!$rs || !$rs instanceof record) {
			throw new Exception(__('Not a valid record object'));
		}
		
		$columns = $rs->columns();
		if (is_array($exclude)) {
			$columns = array_diff($columns,$exclude);
		}
		
		$xml = "<recordset>
";
		while ($rs->fetch()) {
			$xml .= "<record>
";
			foreach ($columns as $col) {
				$xml .= sprintf('<%1$s><![CDATA[%2$s]]></%1$s>'."
",$col,$rs->f($col));
			}
			$xml .= "</record>
";
		}
		$xml .= "</recordset>
";
		return $xml;
	}
}