I don't use XML bu json. Anyway, it seems to be the same logic.
If I understand your need, you need to give an extra ID (generated by your server), different from the record ID. You could then add it as a new data field in your XML and hide it in the grid. This field would then be available for your client side script.