Jump to content

validating the XML file with the schema


Brunods

Recommended Posts

Hello,I'm still trying to get used to XML & XSD (new for me).I've been running some tests and one doubt showed up:I have my XSD file with my schema, and I have my XML file, that MUST follow what my schema says, right?But how can I know when the XML file DOESN'T fit the schema code, this is an error. But how can I catch this?Thanks :)

Link to comment
Share on other sites

You need to create an application that will validate the XML file against the Schema. Most server side scripting languages provide this ability and if you need it off the web server, there are also desktop applications to do such validation. In any case, validation (today) is not done automatically when the file is parsed.

Link to comment
Share on other sites

  • 2 weeks later...
But how can I know when the XML file DOESN'T fit the schema code, this is an error. But how can I catch this?
As robot said,
You need to create an application that will validate the XML file against the Schema. Most server side scripting languages provide this ability...
What robot refers to is called the DOM, or Document Object Model.Standard steps for using XML: (there are other ways, but this is the common one)1) Load it in a DOM parser2) Make the DOM parser validate it3) access the DOM (not the XML) to get informationPHP5, .Net, and Java have very good DOM implementations.However, something tells me that's not really your goal. If you're like most, you're actually trying to validate two files that you just wrote while learning XML and trying to see if they are correct. You noticed that the w3c does not host a validator (why they do not is beyond me). The first site I've found that claims to do this is http://www.xmlvalidation.com/. I cannot vouch for its suitability, as I haven't used it, but I claims to work.//Matt
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...