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)

Problem parsing XML with en-dash character

(0) ShareShare
ReportReport
Posted on by 655

I have a plugin that reads an XML file.  The plugin fails with the following error:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Data at the root level is invalid. Line 1, position 1.Detail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">

I've tried following headers in the XML file but none of them seem to work:

<?xml version="1.0" standalone="yes"?>

<?xml version="1.0" encoding="utf-16" standalone="yes"?>

My XML does have an 'en-dash' character.  The funny thing is that, the same code that runs the plugin also runs in a console app and it works perfectly.  

What are my options? 

 

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    M I Mostafa Profile Picture
    4,257 on at

    Hi Luke,

    Check if your XML tags are all formatted properly with no tags without a missing tag or with a mis-spelt mis-closed tag, etc.

    Hopefully this may be the issue. Otherwise, could you also check the data within the root tag as it might be an error due to invalid characters etc.

    Thanks

    Mohamed

  • SavvyLuke Profile Picture
    655 on at

    I've checked and double checked.  Here is my XML.  Take a crack at it:

    <?xml version="1.0" encoding="utf-16"?>
    <ArrayOfCategory xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema">
      <Category>
        <categoryID>0</categoryID>
        <categoryName>Sales</categoryName>
        <SubCategories>
          <Subcategory>
            <subcategoryID>838170003</subcategoryID>
            <subCategoryName>New Sales – Seasons</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170004</subcategoryID>
            <subCategoryName>New Sales – Partials</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170005</subcategoryID>
            <subCategoryName>New Sales – Groups</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170006</subcategoryID>
            <subCategoryName>New Sales – General</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170007</subcategoryID>
            <subCategoryName>Cross-Sell – Seasons</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170008</subcategoryID>
            <subCategoryName>Cross-Sell – Partials</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170009</subcategoryID>
            <subCategoryName>Cross-Sell – Groups</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170010</subcategoryID>
            <subCategoryName>Cross-Sell – General</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170011</subcategoryID>
            <subCategoryName>Up-Sell – Seasons</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170013</subcategoryID>
            <subCategoryName>Up-Sell – Partials</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170014</subcategoryID>
            <subCategoryName>Up-Sell – Groups</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170015</subcategoryID>
            <subCategoryName>Up-Sell – General</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170016</subcategoryID>
            <subCategoryName>Additional Single Ticket Purchase</subCategoryName>
          </Subcategory>
          <Subcategory>
            <subcategoryID>838170017</subcategoryID>
            <subCategoryName>Dynamics Campaign</subCategoryName>
          </Subcategory>
        </SubCategories>
      </Category>
    </ArrayOfCategory>

    Notice the 'en-dash' in my sub categories at the top.  CRM cannot handle them.  That's the 'special character'.  Encoding with 'utf-16' should solve that problem but in this case it doesn't.

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