Xurkitree is an Ultra Beast also known as UB-03 Lightning. It looks like a bunch of electric wires and unleashes astonishing electric shocks. In Pokemon Sun and Moon, you can find it at Memorial Hill/Lush Jungle. It uses a special attack called 'Discharge' that drains its opponent in one go. Here is a Pokemon Sun and Moon Tip to catch Xurkitree.
The Pokemon used in this battle follows this order: Solgaleo, Lurantis, Komo-o, and Primarina. The team you build in catching Xurkitree depends on the Pokemon Sun and Moon tip you have.
Release Solgaleo and power him up with a Z-move. Then, he will make his first attack using the Zen Headbutt. Xurkitree fights back by using the Electric Terrain filling the battlefield with electric field. Put Solgaleo back into the Pokeball and release Lurantis.
Before Lurantis can even make a move, Xurkitree will use Discharge twice and drain Lurantis' power. Don't worry as this part of the strategy. Lurantis will faint after its energy got drained. Return it to the Pokeball.
Xurkitree will use Beast Boost to increase its special attack. Release Komo-o. Xurkitree will use Discharge again and let Komo-o fight back using his special attack. Xurkitree weakens so use a Beast ball to catch it. However, it will escape but the electric current in the battlefield will disappear.
Use Solgaleo again and use a Beast ball to catch it. It will use Discharge to defeat Solgaleo. Now, it's time to release Toucana and use another Beast ball to catch it. It will break free once again and use Discharge against Toucana.
Lastly, let Primarina out of the box and use another Beast Ball. You will be able to catch it at that time. Congratulations, you are now the new owner of Xurkitree. After that register him at the Pokedex.