XML : nbsp issue reading XML

There are several posts on this issue but none of the solutions seem to work for me. Not sure what I'm doing wrong. I'm trying to read an XML file that looks like this:

  <?xml version="1.0"?>  <content languageCode="en" languageID="1">    <ftypeparser>c:\users\pdeoliveira\Documents\Xmlparsernew.xml</ftypeparser>    <xmlparser>c:\users\pdeoliveira\Documents\Xmlparser.xml</xmlparser>    <sourcelocation>c:\localization\2015</sourcelocation>    <rpkfile>RPK_DefaultSyllabi_2015.xml</rpkfile>    <loglocation>c:\users\pdeoliveira\Documents\Buildloc_Log.txt</loglocation>    <losefiles><locfile>c:\localization\2015\Strings.xml</locfile></losefiles>  </content>    

Here's the code that reads it:

          XmlDocument doc = new XmlDocument();          string filetoload = "config.xml";              try              {                  doc.Load(filetoload);              }              catch (Exception e)              {               Console.Writeline(e);              }    

And here's the exception I get:

  System.Xml.XmlException: Reference to undeclared entity 'nbsp'. Line 1960, position 12.      at System.Xml.XmlTextReaderImpl.Throw(Exception e)      at System.Xml.XmlTextReaderImpl.HandleGeneralEntityReference(String name,       Boolean isInAttributeValue, Boolean pushFakeEntityIfNullResolver, Int32  entityStartLinePos)      at System.Xml.XmlTextReaderImpl.ResolveEntity()      at System.Xml.XmlLoader.LoadEntityReferenceNode(Boolean direct)      at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)      at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)      at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)      at System.Xml.XmlDocument.Load(XmlReader reader)      at System.Xml.XmlDocument.Load(String filename)      at ConsoleApplication9.Program.getrestype(String fname) in  c:\Users\pdeoliveira\Documents\Visual Studio  2013\Projects\BuildLoc\BuildLoc\Program.cs:line 1067    

I tried using the declaration for nbsp like suggested in other posts:

  <!DOCTYPE doctypeName [     <!ENTITY nbsp "&#160;">  ]>    

That didn't work either. The interesting thing is that my file is only 10 or so lines long and it points to an issue on line 1960...?? Any help would be appreciated.

No comments:

Post a Comment