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
8/27/2007 10:51:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 52

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
mahotrash (1778)
8/28/2007 11:00:06 AM

Similar Artilces:

error starting outlook 2k2
this is a pIII with microsoft xp+sp2 and office xp+sp3. whenever i start Ms outlook, a windows pop up saying: "unable to start processing services. could not open the item. try again." what is that and how can i solve it. appreciate your quick reply. ...

Custom CRM Reporting Errors
I have the same problem as Eric. He wrote: "I have an interesting situation. I have Crystal Report 9.2.2 installed locally on the CRM server and I have it installed on my desktop computer. Both can connect and open CRM reports. Below are the differences: From the Crystal Reports installed locally on the CRM Server: 1) I can NOT save modified reports to the CRM. Even if I do I save as and change the name. I get this error: "Critical error while attempting to communicate with the APS." 2) I can verify the database and get informed by Crystal found changes and fixed the report....

More robust Shipping Feature
Shipping Feature should have all of the major shipper (UPS, USPS, FedEx) built in. It should also have the ability to link directly with the shipper internet communication with the ability to do automatic shipping cost calcuation for different shipping mode right from RMS. Just like the API link interface that is used with ecommerce website. Lastly, make USPS tracking from RMS works. Try ship rush "Natt" <> wrote in message > Shipping Feature should have all of the major shipp...

DLookUp #Error
Hello Could anyone help me solve this problem please? I have been looking at this expression for an hour and just couldn't figure out where the problem is. =DLookUp("TotalUnit","OpeningBal","[ProductName] = " & [ProductName]) This expression is in a report where I would like to pull some total number for each product out of a query "openingbal" The openingbal query is as follows, the txFrom datetime value is provided. SELECT ProductName, Sum(nz([Purchased])-nz([Given])) AS TotalUnit FROM Transactions WHERE TransactionDate<Form...

401k Updiate Retirement Account Error
I am receiving an error on only 1 of my 3 401k accounts whenever I go into "more investing tasks" --> "update retirement account" in MS DLX 2007. The specific error is a dialogue box that says "This operation cannot be performed" and then prompts me for more info which takes me to this link: Furthermore, this dialogue box provides me an "ok" and "more info" button. The "...

Outlook reports send error, fails again and again, but messages are going anyway!
Hi, My outlook XP is being very odd. I have been trying to send some digital images (750kb, over cable broadband) to some friends. When I do this, Outlook reports that there was an error waiting for the outgoing server to respond, and the message appears unsent. It keeps trying to send, and after a few goes McAfee starts whining about possible worm activity, so I cancel everything and delete the message from my outbox. However, the messages are being sent. Repeatedly. Last time I put my own email adress in the to: field as well and received 8 copies of the email. I suspect I have some ...

Getting MEDIAN and PERCENTILE to exclude #ERROR values
Is there a way to get PERCENTILE or MEDIAN to exclude error values? I give as an argument a range in which some of the values are #VALUE, but rest are valid, legal numeric values, and it is those remaining non-error values that i want MEDIAN or PERCENTILE of. Thank you. Try the following formulas, which need to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER... =MEDIAN(IF(ISNUMBER(A2:A100),A2:A100)) and =PERCENTILE(IF(ISNUMBER(A2:A100),A2:A100),0.8) Adjust the references and percentile value accordingly. Hope this helps! In article <UTqfg.2573$hv1.1679@trnddc01>, &...

Deserialization from database
We are serializing custom business objects using XML serialization, shredding them in a stored procedure in SQL 2005 in order to get the values into all of the tables in one call. The problem comes when the data comes back out. We are using FOR XML to get XML back out of the database using ExecuteReader (.Net 2.0). Everything works fine until the business object that we are thrying to deserialize creates a document larger than 2K. At this point, the data is truncated and the deserialization fails. I am assuming (but would like clarification) that, by default, UTF-8 is used by the r...

Authentication Error after installation CRM 3.0
Hello I installed CRM 3.0 but i am getting Authentication Error after installation. Setup looks like One AD, 3 domain contorlers, I installed CRM on the one Domain controler. SQL 2000 SP4 and CRM 3.0 are on the same box. Exchange server is on the other box and working properly. i am member of DomainSP4 and then CRM 3.0 and underinstallation i did not get any error and it looks good but after installation i got error message at first attempt to login CRM via web prowser. 1: Authentication Error Microsoft CRM could not log you on to the system. Make sure your user record is enabled and tha...

Error on TransferText when converting Access 97 to Access Xp
The instruction TransferText is use to create a file from a table. This program works very well (many years) on access 97. Afer the convertion to access xp I have the error : "Cannot update .." I went to Newsgroups and see that for security reason MS oblige me to change my file extension .doc to a file extension .txt. So now, I use a text file and I have always on the TransferText instruction the error : "The insert into statement contains ...unknow field name" What can I do to resolve this convertion problem ? Thank you for advance for your answers. ...

error messge #2
I am unable to use my address book in outlook. I get an error message of cannot find LDAP Directory Server (81). Can anyone help me with this? You receive a "Can't contact LDAP Directory server (81)" error message when you open the Address Book in Outlook;en-us;836205&Product=off2003 --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google...

Clip Org. error code
When I go to open up the clip org. (with office doc. or by itself) an error comes up saying error in the DLL error # Ox800401F9. I checked and updated the MDAC and it made no difference. I am running Windows XP with Office XP Ver. 2002 and Publisher 2002 Also have checked the updates and have both service updates. Any other ideas? Might try this Clip2002: "Pure Virtual Function Call" Error When You Start Clip Organizer;en-us;293831 This article has some information if you have PCAnywhere installed Clip2002: "Clip Organiz...

User Access Error #2
This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C3E75A.6A944280 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi I have to admit here to a huge blunder.=20 I have installed CRM 1.2 ok, users are in Active Directory. Logged in as the server administrator (active directory entry) rather = than a crm administrator (kind of the same thing really). In the process of creating Business Units etc I decided I wanted to "see = what happens" if I disable the top Business Unit. In this case Microsoft CRM. Nice...

Trap error for trendline clear button?
Hi everyone I have 2 data series on an XY scattergraph. I have created buttons for turning the associated trendlines ON/OFF. Trendline 1 is the trendline for series 1. The sheet opens with trendline 1 on and trendline 2 off One button (A) turns trendline 1 off and trendline 2 on The other button (B) does the opposite (turns trendline 2 off and trendline 1 on) The idea is that one trendline replaces the other. However, if the user clicks the 'wrong button' (e.g clicks A when trendline 1 is already off) I get a runtime error 1004 (unable to get the trendline properties of the series cla...

Multiple Errors
1. When I try to open a word document straight from an email, nothing happens. I double-click or right-click then "open" and nothing happens. I can save the file, open the word program and then open the file -but no word docs open straight from the email itself. I have checked the temp folder, and gone through detect & repair multiple times -all with no result. 2. When composing an email i cannot click in the message body or the scroll bar. The only option for getting to the message body is to "tab" to it. any suggestions would be greatly appreciated ...

extracting a XML segment (element)
Hello, I need to extract an element from a xml document something like this <myXml> <Header> <Name/> <LastName/> <Age/> </Head> <Body> <Properties> <Address/> <Location/> <Country> </Properties> </Body> </myXml> I need to extract from my Stream the <Properties> element (and sub elements) located inside the Body element. How can I do that? Thanks a lot again! AA I forgot to mention that the element <P...

Custom Workflow Step (4.0): Error Setting Property Value
I have created a custom workflow step in CRM 4.0. I can add this step to my workflow without any issues. The code requires the order id from the workflow. So I go to "Set Properties" for the workflow step and set my property to the Order ID. I can save changes and it seems to work fine, but then when I open up the "Set Properties" window again, the system seems to have saved the value twice. I have tried to delete the value and resave, using other values from the object and I still get the same error. My workflow step then errors, because it's receiving an incorrec...

Error Message when starting
Every time I start publisher I get an error message "out of memory or hard disk full" neither is accurate. Does anyone have suggestions for correcting this? David Every version of Publisher may give an out of memory error, each version may have a different reason for the error. It is helpful to know what version you are using. -- Mary Sauer MS MVP news:// "David W" <> wrote in message news:322b01c4a801$995625d0$a601280a@phx.gbl... > Every time I...

Outlook send error
One of my users this morning came across this issue when trying to send an email. He tries to send an email with Outlook 2000, using Exchange 2000, he hits send and the first error is "Operation Failed". You hit OK, hit send again and this comes up "You do not have permission.... Check folder contact or system administrator" Any one with any idea? I have scoured support, and Outlook help and cannot find anything. Thanks in advance. ...

Robust Server using Sockets
Hi, I want to develop a server application which can handle 1 million clients. I plan to use asynchronous tcp/ip sockets to handle clients. The communication is not frequent and the data transfered is also less(Max 100kb packet) I have some ideas to implement it 1. To have a single server which will service all the 1 million clients. Server will listen to the connections on a particular port and once connected will keep the connection open forever. 2. To have a single server which will service all the 1 million clients. Server will send data in one port and receive data in other port. Onc...

Error in Release version
Hi, when I quit my app (Debug version), everything is OK, but when I set configuration to Release, an error occurs (memory cannot be "written"). I cannot normally debug in Release version, so I can't locate line with error. Please help! -- Deli Read the article "Surviving the Release Version" -- Cheers Check Abdoul [VC++ MVP] ----------------------------------- "Deli" <> wrote in message news:cjch1n$8d5$ > Hi, > when I quit my app (Debug version...

Error Accessing File
I have several problems and need to explain them slowly, that is why I ask for a nurse maid. I am using Access 2000 but ultimatley must convert the Database to Access 97 for usage in VB6. In my test data base in AC2000 every thing works OK. When I export to the other DB which is also at this time in AC2000 it supposedly exports. When I go to use the code section I get a message "Error Accessing file. Network connection may have been lost." I don't know what is going on and can not make corrections. How do I clear this error? Andy Pagorek Andy this sounds like this ve...

trying to exmerge a milbox and get the above error in exmerge.log file. The only thing on Microsoft's website is that this might be caused by Antivirus scanning attachements. So I've dsiabled antivirus rebooted machine. Same error. Uninstall antivirus, reboot machine. Same error. What else can i do to fix the issue. Thank You PS: Try to export to pst from Outlook is unsuccessful as well. Get message that some items could not be exported. ...

beginning xml question
i apologize in advance for what i know is a simple question, but i am being exposed to the first time to xml. considering the following string that i receive: <BusinessEntity xsi:type="DynamicEntity" Name="contact" xmlns:xsi="" xmlns=""> <Properties> <Property xsi:type="KeyProperty" Name="contactid"> <Value>{80FB716B-B189-DA11-84BD-0003FFC6732A}</Value> </Property> <Property xsi...

Unknown error when checking mail.
Hi I have just recently resurrected my files via time machine and one of my email accounts no longer downloads my emails. Entourage gives me a message which says: An unknown error has occurred in Entourage. Could not retrieve mail. Account name: "" Error: 16001 The odd thing about this is that the two other accounts on the same server work just fine and I can SEND emails from my account without any issues. I have recreated the account to no avail. Right now all of the messages are being forwarded to my Gmail account. Any advice? Thanks Dave On 11/12/09 ...