Though, to be honest I suspect writing to a Sqlite database and exporting unique values back to XML is probably going to be easier.
Nice idea too. I could just ignore the error when trying to insert a duplicate
https://www.sqlitetutorial.net/sqlite-unique-constraint/