1

I am getting some information in the form of XML.

Before using that xml I want to validate that all the information is in that XML.

For this purpose I will have a master copy of XML, against which i will match all the coming documents.

How can i do this?

skaffman
  • 398,947
  • 96
  • 818
  • 769
sjain
  • 1,635
  • 9
  • 25
  • 35

3 Answers3

0

Looks a lot of work, but you could use XPath depending on the size and structure of your xml. Take a look at http://www.w3schools.com/xpath/default.asp.

Also there is a really good starting tutorial here: http://www.ibm.com/developerworks/library/x-javaxpathapi.html

And if you're willing to do validation through the use of your xsd (if there is one), look at ( XML Schema (XSD) validation tool? )

Community
  • 1
  • 1
Lucas de Oliveira
  • 1,642
  • 11
  • 16
0

A common approach for validating xml is to define a schema (xsd or dtd). A parser can validate the input xml document against all constraints that are specified in the schema document.

This is a common way if you need to make sure, that certains elements are present and that certain values are within a specified value range.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
0

You can refer the following link to see how an xml can be validated against a dtd in java

http://www.roseindia.net/xml/dom/DOMValidateDTD.shtml

Ammu
  • 5,067
  • 9
  • 34
  • 34