web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

An error occurred while parsing EntityName C# Problem

(0) ShareShare
ReportReport
Posted on by 445

Hi Experts,

i try to read a xml file but i always get an error.

Can someone Help me?

Code:

byte[] data = Convert.FromBase64String(ent.Attributes["body"].ToString());
string xml = Encoding.UTF8.GetString(data);

tracingService.Trace(xml);

XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
doc.PreserveWhitespace = false;
XmlNode root = doc.DocumentElement;

LogFile

<?xml version="1.0" encoding="UTF-8"?><lead><sender><firstname>Vol</firstname><lastname>Die</lastname><company>Mascen-Stach e.</company><companyrole>Assistent der Geschäftsführung</companyrole><email>v.dde</email><street>Rud0</street><zipcode>76</zipcode><city>Emmien</city><phone>0746</phone><fax>91</fax><billingname></billingname><billingstreet></billingstreet><billingzipcode></billingzipcode><billingcity></billingcity><excursion>Exkursion 1 - Deutsches Zentrum für Luft- & Raumfahrt (Preis:St.)</excursion><events>Liste der Veranstaltungen</events><eventitem>BMR Mitgliederversammlung mit Wahlen, 08:30 bis 09:45 Uhr</eventitem><eventitem>Maschinenring TEDx (Sonderpreis 19,90 EUR zzgl. MwSt.), ab 16:00 Uhr</eventitem><eventitem>Tag der Maschinenringe inkl. Festakt "Sechzig Jahre" (Preis 299,00 EUR zzgl. MwSt.)</eventitem><invited>false</invited></sender><comment>TdMR 2018</comment></lead>
Fehler in Methode TDMRXMLundPruefung An error occurred while parsing EntityName. Line 1, position 577.

Kind Regards
Léon

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to add

    xml = xml.Replace("&", "&amp;");

    after

    string xml = Encoding.UTF8.GetString(data);

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    This is parsing error you need to replace "&" with  & and also for safe purpose you can replace other elements as well

    Use below code.

     xmlString.Replace("'","'").Replace( "\"", """).Replace(">",">").Replace( "<","<").Replace( "&","&");

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans