Using APIs for java XML validationXML validation can also be done using the java API. A separate package is available with all the available classes and methods. You need to use the package javax.xml.validation if you want to use these classes. As with other XML processing the key to this validation also is to load the XML document, you want to validate, in the Document object. As a part of creating a document object you would need to create a DocumentBuilderFactory and then a DocumentBuilder. Then load the XML document you want to validate into the Document object. Now our next task is to load the schema file to a schema object. For this you need to create a SchemaFactory and then create a schema object to load the schema file. Then the next step is to create a validator object to validate the document source. The validator object has a validate() method that is used to validate the document.
|
|
|||
|
||||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.