Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all , I am reading the XML file by using XDocument.Load(file). it prompt the exception as "refrence to undeclared entity '©' ". Reason behind is, in the xml file entity '©' is there. Is there anybody knows the solution to get out of it..?? Thanks in advance.

Here is the simple code for the reference::

FileInfo fi = new FileInfo(value);
if (!fi.Exists) throw new Exception("xml missing!");

return XDocument.Load(fi.FullName);
Posted

1 solution

An XML file must contain only valid characters:
See here:
http://en.wikipedia.org/wiki/Valid_characters_in_XML[^]

A workaround could be to read the XML file as text
and then replace any unwanted characters.

Then you must parse the cleaned XML string as described here:
https://msdn.microsoft.com/de-de/library/ce3x426k(v=vs.110).aspx[^]
 
Share this answer
 
Comments
Member 10989956 22-Apr-15 9:27am    
From the above link. I found that the entity is not a valid char in Xml which holds UTF-8 format. I converted that entity into UTF-32 before loading i.e.,
(result = Convert.ToInt32(value);). Then It accept the char and loads.
Thank you steve.:-)
TheRealSteveJudge 22-Apr-15 9:29am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900