Using string equality to compare XML files is unwise, unless you are testing an XML-generation library and care about pretty printing.
In all other cases, you probably care about the semantic equality of the two files (i.e. do they contain the same data?). To aid with such a comparison, consider using XMLUnit. This will compare the contents of your files, without worrying about whitespace or encoding.