Index: CHANGES.html
===================================================================
--- CHANGES.html	(revision 3788)
+++ CHANGES.html	Mon Jun 29 16:05:42 CEST 2009
@@ -78,6 +78,7 @@
 		<li><a href="http://dev.fckeditor.net/ticket/3829">#3829</a> : Fixed remove empty link on output data.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/3730">#3730</a> : Indent is performing on the whole
 			block instead of selected lines in enterMode = BR.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/3801">#3801</a> : Comments at the start of the document was lost in IE.</li>
 	</ul>
 	<h3>
 		CKEditor 3.0 RC</h3>
Index: _source/core/htmlparser/fragment.js
===================================================================
--- _source/core/htmlparser/fragment.js	(revision 3712)
+++ _source/core/htmlparser/fragment.js	Fri Jul 03 14:47:38 CEST 2009
@@ -104,11 +104,11 @@
 
 			// If the target is the fragment and this element can't go inside
 			// body (if fixForBody).
-			if ( fixForBody && !target.type && !CKEDITOR.dtd.$body[ element.name ] )
+			if ( fixForBody && !target.type && !CKEDITOR.dtd.$body[ element.name ] && element.name != '?xml:namespace' )
 			{
 				var savedCurrent = currentNode;
 
-				// Create a <p> in the fragment.
+				// Create fixForBody element in the fragment.
 				currentNode = target;
 				parser.onTagOpen( fixForBody, {} );
 
Index: _source/plugins/htmldataprocessor/plugin.js
===================================================================
--- _source/plugins/htmldataprocessor/plugin.js	(revision 3782)
+++ _source/plugins/htmldataprocessor/plugin.js	Fri Jul 03 14:48:43 CEST 2009
@@ -196,6 +196,7 @@
 	}
 
 	var protectStyleTagsRegex = /<(style)(?=[ >])[^>]*>[^<]*<\/\1>/gi;
+	var protectCommentsRegex = /<!--([\s\S]*?)-->/gi;
 	var encodedTagsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;
 	var protectElementNamesRegex = /(<\/?)((?:object|embed|param).*?>)/gi;
 	var protectSelfClosingRegex = /<cke:param(.*?)\/>/gi;
@@ -205,6 +206,11 @@
 		return '<cke:encoded>' + encodeURIComponent( match ) + '</cke:encoded>';
 	}
 
+	function protectCommentsTagsMatch( match )
+	{
+		return '<cke:encoded>' + encodeURIComponent( match ) + '</cke:encoded>';
+	}
+
 	function protectStyleTags( html )
 	{
 		return html.replace( protectStyleTagsRegex, protectStyleTagsMatch );
@@ -217,6 +223,10 @@
 	{
 		return html.replace( protectSelfClosingRegex, '<cke:param$1></cke:param>' );
 	}
+	function protectComments( html )
+	{
+		return html.replace( protectCommentsRegex, protectCommentsTagsMatch );
+	}
 
 	function unprotectEncodedTagsMatch( match, encoded )
 	{
@@ -256,6 +266,25 @@
 		return data;
 	}
 
+	function filterWithInnerHtml( data )
+	{
+		var div = document.createElement( 'div' );
+
+		// IE: Comments at the start of the document get lost (#3801)
+		if ( CKEDITOR.env.ie )
+		{
+			div.innerHTML = protectComments( data );
+			data = div.innerHTML;
+		}
+		else
+		{
+			div.innerHTML = data;
+			data = div.innerHTML;
+		}
+
+		return data;
+	}
+
 	CKEDITOR.plugins.add( 'htmldataprocessor',
 	{
 		requires : [ 'htmlwriter' ],
@@ -310,9 +339,7 @@
 
 			// Call the browser to help us fixing a possibly invalid HTML
 			// structure.
-			var div = document.createElement( 'div' );
-			div.innerHTML = data;
-			data = div.innerHTML;
+			data = filterWithInnerHtml( data );
 
 			if ( CKEDITOR.env.ie )
 				data = unprotectEncodedTags( data );
