Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 65945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:01:33+00:00 2026-05-10T19:01:33+00:00

I’ve got a little c# windows service that periodically pulls xml from a web

  • 0

I’ve got a little c# windows service that periodically pulls xml from a web service and stores the data in a database table.

Unfortunately it’s failing because the web service has occasional bad data in it – strings instead of decimals. I don’t have any control over the web service (unvalidated user input from software we can’t change) but I would like to log the bad data so that it can be re-input.

It’s simple data that looks something like this:

<ROWS>   <ROW>     <COL1>5405</COL1>     <COL2>102.24</COL1>   </ROW>   <ROW>     <COL1>5406</COL1>     <COL2>2.25</COL1>   </ROW> </ROWS> 

The table just has two columns, COL1 (NUMBER, 10), COL2 (NUMBER, 10,2).

I was using a validating XmlReader and this XSD:

 <?xml version='1.0' encoding='utf-8'?>     <xs:schema id='ROWS' xmlns='' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>       <xs:element name='ROWS' msdata:IsDataSet='true' msdata:Locale='en-US'>         <xs:complexType>           <xs:choice minOccurs='0' maxOccurs='unbounded'>             <xs:element name='ROW'>               <xs:complexType>                 <xs:sequence>                   <xs:element name='COL1' type='xs:decimal' minOccurs='0' />                   <xs:element name='COL2' type='xs:decimal' minOccurs='0' />                 </xs:sequence>               </xs:complexType>             </xs:element>           </xs:choice>         </xs:complexType>       </xs:element>     </xs:schema> 

then a dataset.ReadXml() and Update()ing the dataset.

Whenever it hits bad data I get the following exception:

System.Xml.Schema.XmlSchemaValidationException was unhandled

Message=’The ‘COL1’ element is invalid – The value ‘A40’ is invalid according to its datatype ‘http://www.w3.org/2001/XMLSchema:decimal‘ – The string ‘A40′ is not a valid Decimal value.’

I can think of several ways of ways of getting around the problem but they all feel like a bit of a kludge and I’d like to learn something more elegant, and improve my knowledge. Here’s what I’ve come up with so far:

  • Pre-process the XML provided by the web service before loading into the validating XML reader, removing any bad nodes entirely.
  • Catch the XmlSchemaValidationExceptions and try to continue from them gracefully (not sure about that one)
  • Don’t use a validating XML reader, but instead catch exceptions when loading the unvalidated xml into the dataset. (again not sure about that)
  • have string columns in the dataset, and ignore bad data until I update it, and catch anything the database rejects.
  • go and stand over the users with a large mallet until they learn to get it right first time (too time consuming)
  • something else?

UPDATE: The data can be bad because it comes from a application that doesn’t validate the user input for COL1 – but the numbers in COL2 are calculated correctly, and COL1 should correspond with a different system. Any invalid entries should be recorded so they can be corrected. After the data is written to the database, another system verifies that COL1 is valid, and the users will soon spot if it doesn’t show correctly in the other system – they used to load it by hand anyway 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:01:34+00:00Added an answer on May 10, 2026 at 7:01 pm

    Pre-process the XML provided by the web service before loading into the validating XML reader, removing any bad nodes entirely.

    This is the option I would choose, it would allow you to grab the bad input before the exception and store it somewhere so it can be looked at later. Then you can find the offending user and use another of your methods

    go and stand over the users with a large mallet until they learn to get it right first time

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 96k
  • Answers 96k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What your talking about is called normalization, and what you… May 11, 2026 at 7:10 pm
  • Editorial Team
    Editorial Team added an answer You will need to do it "backwards"; list all the… May 11, 2026 at 7:10 pm
  • Editorial Team
    Editorial Team added an answer To learn more about collations: SQL Server Collation Fundamentals In… May 11, 2026 at 7:10 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.