First, did you pay all the interest or did your ex pay some of the interest? If your ex paid some of the interest, it may or may not be deductible.
Second, is the interest on the two 1098s more than the total that was paid for the year (they overlap) or does one have the interest from the original loan only and one has the interest from the refi only?
----------
If, you paid all the interest for the year, and the 1098s don't overlap (one is original only and one is refi only) then you can claim both 1098s. If your spouse's SSN is on the first 1098, you will need to check the box for "my SSN is not on this 1098". This will bring up a box to write an explanation. Make it simple but clear. ("My ex-spouse's SSN is listed, but it was a joint loan and I made all the payments.")
If your situation is unclear, reply with more details.