problem with & in xml document

Posted on 2010-09-21
Last Modified: 2012-05-10
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

Question by:Borsec
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 42

Expert Comment

ID: 33723485
can u post the xml?

Accepted Solution

CyberSoft earned 500 total points
ID: 33741916
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.


Author Comment

ID: 33751371
Thanks! The problem is solved.
You're right, I found an simple '&'  in my XML file.

Expert Comment

ID: 33751583
Great. Please mark this question as answered :)

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question