Поделиться через


Unsuccessfully Modifying RTE2ToolbarExtension.xml

If you have modified RTE2ToolbarExtension.xml file and browsed back your SharePoint publishing site and found this exception on your screen or in the ULS logs, you’re not alone.

System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at
System.Xml.XmlTextReaderImpl.Throw(Exception e) at
System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at
System.Xml.XmlDocument.Load(XmlReader reader) at
Microsoft.SharePoint.Publishing.Internal.CodeBehind.RTE2PUEditor.ReadHtmlEditorExtensionsConfigFile(Page page) at
Microsoft.SharePoint.Publishing.WebControls.HtmlEditor.RegisterScriptsV2() at
Microsoft.SharePoint.Publishing.WebControls.HtmlEditor.OnPreRender(EventArgs e) at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   

 

This exception is a result of the content of RTE2ToolbarExtension.xml file not having the correct file encoding, the file needs to be ASCII encoded, which is not the default format for Visual Studio.  Visual Studio defaults to UTF-8 encoding.  You have two options, first is to save the file type in VS using the correct format, using the Save As option, and selecting the Save with Encoding option in the Save File As dialog.  Choose US-ASCII – CodePage 20127 option.

image

 

A second option is to use PowerShell to convert an existing file using the following syntax:

 Get-Content "C:\RTE2ToolbarExtension.xml" | 
 Set-Content "C:\RTE2ToolbarExtension.xml" -Force -Encoding Ascii

Either conversion option will allow you to upload the newly encoded version of RTE2ToolbarExtension.xml to the Editing Menu folder and be error free.