Robust deserializer - Handling errors in XML - XML SOAP

This is a discussion on Robust deserializer - Handling errors in XML - XML SOAP ; I am using XmlSerializer to deserialize XML, and sometimes have to deal with legacy files with slight differences, for example "yes" where "Yes" is expected, i.e. Expected: <Enabled>yes</Enabled> Actual: <Enabled>Yes</Enabled> This causes an "InvalidOperationException" and terminates the deserialization. I would ...

+ Reply to Thread
Results 1 to 2 of 2

Robust deserializer - Handling errors in XML

  1. Default Robust deserializer - Handling errors in XML

    I am using XmlSerializer to deserialize XML, and sometimes have to deal with legacy files with slight differences, for example "yes" where "Yes" is expected, i.e.

    Expected: <Enabled>yes</Enabled>

    Actual: <Enabled>Yes</Enabled>

    This causes an "InvalidOperationException" and terminates the deserialization. I would prefer my code to be able to examine the cause of the exception, and recover and continue if possible. What is the best way to achieve this?

    Many thanks
    Max

  2. Default Re: Robust deserializer - Handling errors in XML

    Max wrote:
    > I am using XmlSerializer to deserialize XML, and sometimes have to deal with legacy files with slight differences, for example "yes" where "Yes" is expected, i.e.
    >
    > Expected: <Enabled>yes</Enabled>
    >
    > Actual: <Enabled>Yes</Enabled>
    >
    > This causes an "InvalidOperationException" and terminates the deserialization. I would prefer my code to be able to examine the cause of the exception, and recover and continue if possible. What is the best way to achieve this?


    Why &lt;Enabled&gt; and not <Enabled>? And why is Yes a problem? That
    depends solely on the type definition for the Enabled element
    respectively property.
    I am not sure there is a way to recover, I rather think you need to find
    a way to transform the "legacy" XML to the current XML. XSLT is one way
    to do that.


    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

+ Reply to Thread

Similar Threads

  1. runtime errors default handling?
    By Application Development in forum xharbour
    Replies: 2
    Last Post: 12-16-2007, 07:22 PM
  2. Handling errors in ASP.NET AJAX
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 11-14-2007, 04:53 AM
  3. Handling errors within templated classes
    By Application Development in forum c++
    Replies: 11
    Last Post: 11-02-2007, 03:44 AM
  4. Problems Handling Errors Correctly
    By Application Development in forum CSharp
    Replies: 39
    Last Post: 09-18-2007, 03:50 PM
  5. Handling DataGridView Errors
    By Application Development in forum CSharp
    Replies: 0
    Last Post: 09-11-2007, 01:00 PM