tags:

views:

845

answers:

3

I have the following line of code:

XDocument formConfiguration = XDocument.Load(ConfigurationManager.AppSettings["XMLFileURL"]);

I get the following exception message:

Reference to undeclared entity 'nbsp'

There are no   sequences in the XML. There are no "&" characters in the XML. Where could this be coming from?

Thanks, Charles

A: 

it looks like there should be an   in your file. I'd recommend using an XML validator to make sure that the XML file you are trying to read is well-formed. W3Schools has one here

Josh E
Both the XML file I'm trying to load, and the web.config of my application containing the relevant appSettings section, both come out clean.
Have you done a text search for 'nbsp'? Are there any characters that match that string in your XML?
Josh E
None. The string doesn't exist within the XML.
what's the value of the app setting XMLFileUrl? Is it fully qualified? I don't think it should matter, but wouldn't hurt to try just for testing
Josh E
A: 

Could it be there was an   declaration, which is an issue, because ampersand (&) isn't allowed for XML documents?

Zack
You could mention changing   to   for conformance.
sixlettervariables
There are no space entities in the XML.
A: 

Found the answer; XDocument.Load works better with a file path rather than a URL. It works now. Thanks everyone.