X-ray fluorescence (XRF) spectroscopy offers a fast and efficient method for analysing soil elemental composition, both in the laboratory and the field. However, the technique is sensitive to spectral interference as well as physical and chemical matrix effects, which can reduce the precision of the measurements. We systematically assessed the XRF technique under different sample preparations, water contents, and excitation times. Four different soil samples were used as blocks in a three-way factorial experiment, with three sample preparations (natural aggregates, ground to ≤2 mm and ≤1 mm), three gravimetric water contents (air-dry, 10% and 20%), and three excitation times (15, 30 and 60 s). The XRF spectra were recorded and gave 540 spectra in all. Elemental peaks for Si, K, Ca, Ti, Fe and Cu were identified for analysis. We used analysis of variance (anova) with post hoc tests to identify significant differences between our factors and used the intensity and area of the elemental peaks as the response. Our results indicate that all of these factors significantly affect the XRF spectrum, but longer excitation times appear to be more defined. In most cases, no significant difference was found between air-dry and 10% water content. Moisture has no apparent effect on coarse samples unless ground to 1 mm. We suggested that the XRF measurements that take 60 s from dry samples or only slightly moist ones might be an optimum option under field conditions.