Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

problem with & in xml document

Posted on 2010-09-21
4
Medium Priority
?
287 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:Meir Rivkin
ID: 33723485
can u post the xml?
0
 
LVL 3

Accepted Solution

by:
CyberSoft earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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