Mahdi Giveie
Mahdi Giveie

Reputation: 640

Comparing two XML files Android

I want to compare two XML files, they are the same as each other. i have one of them in local storage and using bufferReader i put it on String and i get the other one from server and again put it into the String! then i Print the content of them and they are actually the same! nothing differs even spaces!! but when i compare them ( 2 strings) using equalsIgnoreCase they are not equal and always goes to else! which means they are not equal! can anybody help on this? if no way to compare like this so how can i compare them?

Upvotes: 1

Views: 854

Answers (2)

Arun Kumar
Arun Kumar

Reputation: 877

Did you tried string1.equals(string2)

Upvotes: -1

Tanmay Mandal
Tanmay Mandal

Reputation: 40168

I think it happens due to formatting issue.

You can use XMLUnit to resolve the issue.

XMLUnit will help you in

  • The differences between two pieces of XML
  • The outcome of transforming a piece of XML using XSLT
  • The evaluation of an XPath expression on a piece of XML
  • The validity of a piece of XML
  • Individual nodes in a piece of XML that are exposed by DOM Traversal

Upvotes: 2

Related Questions