How can I compare two HTML strings, disregarding the order of attributes

How can I compare two HTML strings, disregarding the order of attributes

I have got a test that parses XML and appends an element to another on a page.

How can I compare this actual element to an expected string or object, so that the order of attributes does not matter to prevent false positives because of differences caused by cross browser processing

Tom