Error handling in finding parent XML