I am new in XML's and not sure if this is the right place to put my question. I want test XML's wherein I got to check if all the mandatory fields are present in XML or not. Also if there is any new field/node is added to the XML than expected.
Can you please help me knowing if it is possible to achieve and how it can be done.
the usual way to validate XML documents is to provide some kind of schema like a DTD or XML Schema. XML parsers and other tools allow you easily to validate if a document conforms to its schema, i.e. if the structure and content are as expected. XML Schema would be much more powerful than DTDs regarding the constraints you can define for the structure and content of valid documents.
The downside is of course that you would have to make yourself familiar with the schema language in question.
Alternatively the validation can be done completely in code but to provide a schema to validate at least the most important things is much more reasonable in my opinion. After validating against a schema you can add some more detailed validation inside your application code.
My question is, the xsd says for some elements the minOccur is 1. I haven't put any data in the xml. Still the parser is successful without giving any error. Is there any way I can findout if any required field is missing. or may be there is an extra field in the XML then that should also be detected.