You can upgrade from Windows 7, 8, or 8.1 to Windows 10 for free. Once you do that you can do a free upgrade from Windows 10 to 11. Note this assumes the original 7, 8, or 8.1 were activated with a valid product key.
However, this also assumes the computer is not too old and has drivers that work with Windows 10 and 11.
There is absolutely no way Windows XP will work to upgrade to Windows 11. If you try you are just wasting your time.