System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

Dec 15, 2011 at 5:17 PM

I get this issue popping up now and again related to the .config files I use:

System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.   
at Zippy.Chirp.Engines.ConfigEngine.LoadConfigFileGroups(String configFileName)   
at Zippy.Chirp.Engines.ConfigEngine.ReloadFileDependencies(ProjectItem projectItem)   
at Zippy.Chirp.Chirp.IndexDependencies()

It causes the file mash-up not to occur. I haven't had a chance to go through the code but I came across this in a quick Google search:

http://www.west-wind.com/weblog/posts/2007/Feb/04/XmlWriter-Strings-and-Byte-Order-Marks

// *** Create encoding manually in order not to
// *** create leading Byte order marks
Encoding Utf8 = new UTF8Encoding(false);
MemoryStream ms = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(ms,Utf8);

Could the BOM be the issue?  And would it be possible to use use this solution as a fix?

If not, does anyone know of a workaround? It is causing Chirpy not to work for me.

Thanks in advance!

Developer
Dec 17, 2011 at 11:30 PM

More detail.

  1. Config file content.
  2. File type (less,js,css ...)
  3. Engine (Yui,Closure compiler, MsAjax...)
Dec 19, 2011 at 2:29 PM
The error occurs on the JS and CSS config files (named scripts.chirp.config and styles.chirp.config respectively). I have chirpy setup with the defaults, so it is using the YUI engine for both. I'm using Chirpy 2.01 (DLL 2.0.0.1) and I have tried the latest 2.03 with the same issue/result.
Here is the JS config file with the problem:
<root>
	<FileGroup Name="scripts.combined.js">
		<File Path="jquery-1.7.1.min.js" Minify="false" />
		<File Path="jquery-ui-1.8.16.min.js" Minify="false" />
		<File Path="jquery.hoverIntent.min.js" Minify="false" />
		<File Path="jquery.bgiframe.min.js" Minify="false" />
		<File Path="jquery.superfish-1.4.8.min.js" Minify="false" />
		<File Path="jquery.validate.min.js" Minify="false" />
		<File Path="jquery.validate.unobtrusive.min.js" Minify="false" />
		<File Path="mvcfoolproof.unobtrusive.min.js" Minify="false" />
		<File Path="i18n/grid.locale-en.js" />
		<File Path="jquery.jqGrid.min.js" Minify="false" />
		<File Path="jquery.widget.combobox.js" />
		<File Path="json2.js" />
		<File Path="scripts.min.js" Minify="false" />
	</FileGroup>
</root>
Here is the one I'm using now. It works but I had to locally install the schema file:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:ChirpyConfig">
	<FileGroup Name="scripts.combined.js">
		<File Path="jquery-1.7.1.min.js" Minify="false" />
		<File Path="jquery-ui-1.8.16.min.js" Minify="false" />
		<File Path="jquery.hoverIntent.min.js" Minify="false" />
		<File Path="jquery.bgiframe.min.js" Minify="false" />
		<File Path="jquery.superfish-1.4.8.min.js" Minify="false" />
		<File Path="jquery.validate.min.js" Minify="false" />
		<File Path="jquery.validate.unobtrusive.min.js" Minify="false" />
		<File Path="mvcfoolproof.unobtrusive.min.js" Minify="false" />
		<File Path="i18n/grid.locale-en.js" />
		<File Path="jquery.jqGrid.min.js" Minify="false" />
		<File Path="jquery.widget.combobox.js" />
		<File Path="json2.js" />
		<File Path="scripts.min.js" Minify="false" />
	</FileGroup>
</root>
Obviously, manually installing the schema file locally is not the greatest of solutions but I'm happy I found some way to get this great addin working again.
Thanks.
Developer
Dec 31, 2011 at 8:02 PM
Edited Jan 1, 2012 at 1:30 AM

Solve error config file don't run when xmlns="urn:ChirpyConfig" is not present.
http://chirpy.codeplex.com/SourceControl/changeset/changes/de436f4b8392

Other problem save your config file in utf-8.