problem with & in xml document

I have a problem while tried to deserialize a XML file that contains a special character '&'. The error message is “An error occurred while parsing EntityName. Line 14, position 40.”

public static CSettings ReadSettings()
    CSettings ob = null;
    xmlFile = Path.Combine(CDCPath.LocalSystemConfig, SETTINGS_FILE_NAME);
    if (System.IO.File.Exists(xmlFile))
        Stream stream = new FileStream(xmlFile, FileMode.Open, FileAccess.Read, FileShare.Read);
        System.Xml.XmlReader streamReader = System.Xml.XmlReader.Create(stream);
        System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer
        ob = (CSettings)serializer.Deserialize(streamReader);
    return ob;

Open in new window

Who is Participating?
Make sure your XML does not simply contain the & but that it contains the entity &amp; - also you cannot have non-alpha-numeric characters in XML nodes and attributes - only contained within <[CDATA[  ]]> sections.

Meir RivkinFull stack Software EngineerCommented:
can u post the xml?
BorsecAuthor Commented:
Thanks! The problem is solved.
You're right, I found an simple '&'  in my XML file.
Great. Please mark this question as answered :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.