How To Root Sony Xperia XA2 Ultra H3223

First you need to check what model do you have and if your boot-loader is unlock-able, to check the model go to Settings → About phone and you should be able to see your model number, also notice your IMEI number, write them down because we will need them. And while you are at it, you should enable developer option by clicking on Build Number 7 times, go back to the Settings menu and enter developer options and enable USB debugging and Unlock OEM

How To Root Sony Xperia XA2 Ultra H3223
Next go to the phone application, type this number *#*#7378423#*#* then tap on Service info → Configuration → Rooting status, if the Boot-loader unlock says yes then your phone is unlock-able and you are ready to go, if not then it isn’t and you should stop reading.
*Take a backup of TA Partition to keep DRM keys Which matters on preferences *
Unlocking your boot-loader will wipe your phone clean
How To unlock bootloader From Here

How To Root Sony Xperia XA2 Ultra H3223

Download Driver From Here
Download Fastboot From Here
Download magiskmanager From Here
It is very important to download the bot file by Build number

Firmware Link
50.1.A.4.76 Download
50.1.A.5.59 Download
50.1.A.8.15 Download
50.1.A.13.83 Download

Install Driver on your PC
Install magiskmanager on your Phone
Then copy the boot file to the Phone memory after Extract the file
Open Magisk
When you open the application 
Click on Install then Install then Patch Boot Image File

How To Root Sony Xperia XA2 Ultra H3223

Then go to the path where you copied the boot file
If you require access, please accept
Wait for the process to finish Patch Boot
It will take about 5 minutes
After the process is finished open the file manager and then go to the folder MagiskManager
You will find a file named patched_boot.img
Copy and paste it into your PC in a folder Fastboot
Then rename the file patched_boot.img to boot.img
To open a folder Fastboot
right-click in the empty space of this folder in File Explorer with the Shift button pressed and choose Open command windows here
Then turn off the phone
press Vol up and Connect USB
Root H3223
In the command line type the following:
adb devices

fastboot flash boot boot.img

Wait to finish
fastboot reboot

The root process has now been completed
To verify use Root Checker

In the event of any problems can communicate with us by clicking on the image