Solved

problem with & in xml document

Posted on 2010-09-21
4
279 Views
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
                    (typeof(CSettings));
        ob = (CSettings)serializer.Deserialize(streamReader);
        stream.Close();
    }            
    return ob;
}

Open in new window

0
Comment
Question by:Borsec
[X]
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
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 33723485
can u post the xml?
0
 
LVL 3

Accepted Solution

by:
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.

HTH
0
 

Author Comment

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

Expert Comment

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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

732 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