System.Xml.XmlException: '/' is an unexpected token. The expected token is '='. Line 24, position 29.

Topics: ASP.NET 2.0
Jun 22, 2009 at 7:24 PM

I did something very stupid, I was trying to update the web pages on my site to be more accessibility compliant by adding a lang="en-US" to every HTML tag. However doing a find and replace on my whole site was very very stupid. I found the problem in App_Data/settings.xml. This caused a problem with the blog because in the XML it changed <htmlheader /> to <html lang="en-US" header/>.  So that is why I got the error that I got. Okay I figure I can just change it back to <htmlheader />. I tried that, but it still gives me the exact same error. I even tried deleting that line and also adding junk code before line 24 just to see if it would recognize it, but it does not. It still gives me the exact same error on the exact same line. Please help! There was very important information on this blog and now I cannot access it!

 

The error specifically is:

 

/' is an unexpected token. The expected token is '='. Line 24, position 29.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Xml.XmlException: '/' is an unexpected token. The expected token is '='. Line 24, position 29.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

[XmlException: '/' is an unexpected token. The expected token is '='. Line 24, position 29.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +76
   System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) +88
   System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2) +167
   System.Xml.XmlTextReaderImpl.ParseAttributes() +3978540
   System.Xml.XmlTextReaderImpl.ParseElement() +343
   System.Xml.XmlTextReaderImpl.ParseElementContent() +121
   System.Xml.XmlTextReaderImpl.Read() +45
   System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) +58
   System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +20
   System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +129
   System.Xml.XmlDocument.Load(XmlReader reader) +108
   System.Xml.XmlDocument.Load(String filename) +87
   BlogEngine.Core.Providers.XmlBlogProvider.LoadSettings() in C:\Documents and Settings\Mads Kristensen\Dokumenter\Visual Studio 2005\Projects\BlogEngine.NET\DotNetSlave.BusinessLogic\Providers\XmlProvider\Settings.cs:46
   BlogEngine.Core.BlogSettings.Load() in C:\Documents and Settings\Mads Kristensen\Dokumenter\Visual Studio 2005\Projects\BlogEngine.NET\DotNetSlave.BusinessLogic\BlogSettings.cs:1640
   BlogEngine.Core.BlogSettings..ctor() in C:\Documents and Settings\Mads Kristensen\Dokumenter\Visual Studio 2005\Projects\BlogEngine.NET\DotNetSlave.BusinessLogic\BlogSettings.cs:223
   BlogEngine.Core.BlogSettings.get_Instance() in C:\Documents and Settings\Mads Kristensen\Dokumenter\Visual Studio 2005\Projects\BlogEngine.NET\DotNetSlave.BusinessLogic\BlogSettings.cs:250
   BlogEngine.Core.Web.HttpModules.ReferrerModule..cctor() in C:\Documents and Settings\Mads Kristensen\Dokumenter\Visual Studio 2005\Projects\BlogEngine.NET\DotNetSlave.BusinessLogic\Web\HttpModules\ReferrerModule.cs:81

[TypeInitializationException: The type initializer for 'BlogEngine.Core.Web.HttpModules.ReferrerModule' threw an exception.]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
   System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
   System.Web.Configuration.Common.ModulesEntry.Create() +39
   System.Web.Configuration.HttpModulesSection.CreateModules() +164
   System.Web.HttpApplication.InitModules() +28
   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729
   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +298
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289

 


Jun 22, 2009 at 7:49 PM

Just to add, this is with version 1.45, I also even tried simply deleting the settings.xml (I restored it though after) just to see if it would throw a different error, but it did not! I don't understand! I even tried installing a new version of BE in another directory and duplication the process. I replaced all <html with <html lang="en-US", check settings.xml, alright, I load the page....and it worked! So maybe I am wrong im assuming it's settings.xml but it seems to fit perfectly with the change that I made the type of error and the line, but I am truely stumped but really need to recover the data from that blog. Any help would be immensely appreciated.

Jun 23, 2009 at 3:26 PM

Well this fixed itself automatically I guess for some reason it wasn't updating when I changed the code, I cleared out my cache yesterday because I thought that might be it, but that didn't do anything. But today, it now works.