public static function _toXML ($params = array (), $attributes = FALSE, &$db = FALSE)
	{
		
		// Set class name for the elements
		// Remove the Sonic\Model prefix and convert namespace \ to _
		
		$class	= str_replace ('\\', '_', str_replace ('sonic\\model\\', '', strtolower (get_called_class ())));
		
		// Create DOMDocument

		$doc	= new \DOMDocument ('1.0', 'UTF-8');
		
		// Create root node
		
		$xml	= $doc->createElement ('elements');
		$doc->appendChild ($xml);
		
		// Get objects
		
		$rows	= static::_toArray ($params, $attributes, $db);
		
		// For each row
		
		foreach ($rows as $row)
		{

			// Create the node

			$node	= $doc->createElement ($class);

			// Set each attribute

			foreach ($row as $name => $val)
			{
				$node->appendChild ($doc->createElement (strtolower ($name), htmlentities ($val)));
			}
			
			// Add node

			$xml->appendChild ($node);

		}
		
		// Return doc
		
		return $doc;
		
	}