I have to compare XML data. There are two sources-
- Web Service
- XML files
I don't see any easy way to transform them in same classes and use equals method.
The classes that work with Web Services are auto generated and WSDL isn't simple at all.
So I read the response from Web Service, read the corresponding file, transform them to String with the same formatting ( removed spaces, \n\r characters, and so on ) and then use String.equals() method.
The issue is the Web services's empty tags are written next way :
<EmptyTag/>
but provided files contains this kind of empty tags:
<EmptyTag></EmptyTag>
OK, there is a way to prepare all provided files manually, but I don't like it. Who knows, how it's possible to transform empty tags to the same style ? If there are any ideas how to simplify to process - you are welcome ;)
UPDATE
I don't parse the xml. The file's data is just read and transformed to expected format. The object's structure from Web Service's response is transformed to xml string in the next way:
marshaller.marshal(new JAXBElement<response_class_name>(new QName("response_class_name"),
response_class_name.class, response_object), stringWriter);