At the office we are currently writing an application that will generate XML files against a schema that we were given. We would prefer free tools that are appropriate for commercial use although we won't be bundling the schema checker so it only needs to be usable by devs during development. Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema?Our development language is C++ if that makes any difference, although I don't think it should as we could generate the xml file and then do validation by calling a separate program in the test.
I've created a small Java project on github to validate from the command line using the default JRE parser, which is normally Xerces. There is also a C++ version of Xerces available if you'd rather use that.
The Std In Parse utility can be used to call it from the command line.
Also, a commenter below points to this more complete wrapper utility.
You could also use xmllint, which is part of libxml. Example usage: One problem is that libxml doesn't implement all of the specification, so you may run into issues :( Alternatively, if you are on Windows, you can use msxml, but you will need some sort of wrapper to call it, such as the GUI one described in this DDJ article.
However, it seems most people on Windows use an XML Editor, such as Notepad++ (as described in Nate's answer) or XML Notepad 2007 as suggested by Steve C (there are also several commercial editors which I won't mention here).
Finally, you'll find different programs will, unfortunately, give different results.This is largely due to the complexity of the XSD spec.You may want to test your schema with several tools. - validate against Relax-NG schema -e or --err - print verbose error messages on stderr -b or --list-bad - list only files which do not validate -g or --list-good - list only files which validate -q or --quiet - do not list files (return result code only) NOTE: XML Schemas are not fully supported yet due to its incomplete support in libxml2 (see XMLStarlet is a command line toolkit to query/edit/check/transform XML documents (for more information see An XML editor for quick and easy XML validation is available at just need to run the installer and after that you can validate your XML files with an easy to use desktop application or the command-line.In addition you also get support for Schematron and Relax NG. Update 1/13/2012: The command line tool is free to use and uses Xerces as XML parser. I'm getting frustrated by the errors coming out of xmlllint. If there is a wrong attribute in the XML then xmllint tells you the name of the unsupported attribute.I found this online validator from 'corefiling' quite useful - After trying few tools to validate my xsd, this is the one which gave me detailed error info - so I was able to fix the error in schema. But if you are missing an attribute in the XML you just get a message saying the element can not be validated.I'm working on some very complicated XML with very complicated rules, and I'm new to this so tracking down which attribute is missing is taking a long time. It can be run from the command line like xmllint and it supports RELAX NG: https://java.net/ You can connect your XML schema to Microsoft Visual Studio's Intellisense.