tags:

views:

7

answers:

1

Hi all,

I have set of XML files and they have a particular stucture. I want to validate the XML so that the stucture is fine always before using it.

Can anyone help with some samples like how to validate the XML files using java code.

Thanks...

+1  A: 

You need to create an XML Schema file (.xsd). This will define which elements may and may not be present in the file.

You can then use Java libraries to check that the XML file you have is compatible against this schema, see here: http://java.sun.com/developer/technicalArticles/xml/validationxpath/

Adrian Smith