Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Problem parsing XML with en-dash character

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

  • SavvyLuke Profile Picture
    SavvyLuke 655 on at
    RE: Problem parsing XML with en-dash character

    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.

  • Suggested answer
    M I Mostafa Profile Picture
    M I Mostafa 4,257 on at
    RE: Problem parsing XML with en-dash character

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans