My new XT was a bit spongy, however I finally managed to get the air bubble out by using a syringe and plastic tube, and the avid method of bleeding.
Which is basically:
fill syringe with fluid
attach tube
flush out air and attach to bleed nipple
move brake lever so its level and remove reservoir cap
undo bleed nipple
pull on brake lever and fix to the bars.
push back pistons with a screwdriver
then with the syringe pull the plunger towards you to create a vacuum, and flick the caliper and this should get the air bubbles out, it may take a few minutes to get the last of the stubborn ones out
once they are all out, release the brake lever and push through liquid very slowly and watch the reservoir (it will overflow, so mop up excess with cloth) once a decent amount has gone through and the bubbles has stopped, put the cap back on and put lever back
bolt caliper back onto the bike
once everything is bolted onto the bike, squeeze it a couple of time and it should go rock solid, if it doesn’t then you missed some air so need to do it again.
or buy a new brakes, but the XTs are very good, so buying more brakes isn’t really necessary unless you just want to spend money.