Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looking for suggestions on how to validate the data in an XML file

Status
Not open for further replies.

PPettit

IS-IT--Management
Sep 13, 2003
511
0
0
US
I want to catch errors in some XML files that I have to transmit to a rather large customer of ours. If their systems decide that some of the data is invalid or missing, I have to figure out what the corrections are supposed to be, and then resubmit the files. Sometimes, it can take a few hours to correct even the least complex files. If I can automate most of this process, I'll be able to save myself a huge amount of time since I usually upload at least 100 of these files every day.

Does anyone know of a relatively easy way that I can validate the data within the files before I ever upload them? Hopefully, there's an existing application or script that will do what I want with just a few modifications. I need to be able to check for things like spelling errors, invalid dates, missing data, and data that's invalid because of other data in the file. An added bonus would be if I could automatically correct these errors as well.

Any suggestions would be appreciated.
 
You need to create an XSD file. These define the structure of an XML file, as well as the datatypes and sizes of the elements. They will not, however, validate the data within the XML file.

You can use a tool like XMLSpy to create the XSD, as well as validate your XML file.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
I concur with chiph, XSD files are the way to go. XSD files or XML schemas are basically the creation of microsoft and the W3C and are used to validate XML documents according to how you want them to be. Get yourself a copy of Visual Studio.Net and it can generate an XML schema for you based your XML document, make sure it's based on a valid and well formed XML document. So I suggest you get together with your customer(s) and define all the data and rules you require in your XML document, then generate away. VisualStudio.Net also allows you to create consoles where you can validate xml documents, against the XML schemas created.
I'm only a novice to this whole XML thing myself. So all XML guru's feel free to correct me on what you think is inaccurate.

Happy B2B!!
 
Thanks for the responses.

I probably should have mentioned that I know very little about the whole XML subject. Our accounting system generates these files automatically and it appears to have absolutely no ability to check the validity of the data that gets put into these files.

I had a feeling that this wasn't going to be as easy as I hoped. However, the info you guys gave me should help to get me on the right path sooner than I would have on my own.

Thanks again.
 
AndiusMaximus :
>>> XSD files or XML schemas are basically the creation of microsoft and the W3C

Ha !

Yeah, because Micro$oft are well known for working with open-source and free-for-all standards and RFCs. Have you ever tried sending an RFC compliant email to Micro$oft exchange ?

VS.NET costs loads of money - don't use it ! There are many free open source Java APIs (and non-Java) out there for manipulating XML which will do the job. Check out the JWSDP from
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top