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 ...
-
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
-
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 <Enabled> 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/
Similar Threads
-
By Application Development in forum xharbour
Replies: 2
Last Post: 12-16-2007, 07:22 PM
-
By Application Development in forum DOTNET
Replies: 1
Last Post: 11-14-2007, 04:53 AM
-
By Application Development in forum c++
Replies: 11
Last Post: 11-02-2007, 03:44 AM
-
By Application Development in forum CSharp
Replies: 39
Last Post: 09-18-2007, 03:50 PM
-
By Application Development in forum CSharp
Replies: 0
Last Post: 09-11-2007, 01:00 PM