Validating xml parser requires
Or you can set your own via set Resource Resolver, ex: Source xml File = new Stream Source(xml File Location); Schema Factory schema Factory = Schema Factory Instance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schema Schema(); Validator validator = Validator(); Resource Resolver(new LSResource Resolver() ); validator.validate(xml File); // parse an XML document into a DOM tree Document Builder parser = Document Builder Instance()Document Builder(); Document document = parser.parse(new File("instance.xml")); // create a Schema Factory capable of understanding WXS schemas Schema Factory factory = Schema Instance(XMLConstants.But then again, validating XML against XSD files is a rather heavy weight problem.As for a tool to do this for you, XMLFox seems to be a decent freeware solution, but not having used it personally I can't say for sure.
This will start creating DOM objects as it parses the document - wasteful if you aren't going to use them.
And that brings up the second case: if you get XML from someone who doesn't know the rules.
For example, XML generated using simple string output in a Windows environment will probably be encoded in .
Useful if you're unmarshalling JAXB objects or extracting data from a large file, not so useful if you're exploring a data structure.
The downside of DOM, of course, is that it's all in memory, and the DOM implementation adds quite a bit to the memory footprint of the data.