开发者

how to match two xml string?

开发者 https://www.devze.com 2023-03-02 22:26 出处:网络
I am getting some information in the form of XML. Before using that xml I wa开发者_如何学Gont to validate that all the information is in that XML.

I am getting some information in the form of XML.

Before using that xml I wa开发者_如何学Gont 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?


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? )


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消