X-rays are electromagnetic radiation, similar to visible light, but occurring at a much shorter wavelength. While visible light ranges from 4000 to 7000 Angstroms (an Angstrom is 1/10,000,000,000th of a meter), X-rays routinely used in crystallography have a wavelength of 0.7 to 1.7 Angstroms. Visible light, infrared heat, and X-rays are all part of the Electromagnetic Spectrum.
We are able to "see" objects with visible light because the objects scatter the light in all directions. Our eyes are capable of differentiating the different wavelengths (or color) and thus an image can be constructed in our mind.
We are able to examine crystals with X-rays for a similar reason. Each atom in a molecule consists of a nucleus surrounded by electrons, the number of electrons determined by the atomic number of the element and the charge on the atom. The electrons present scatter the X-rays in all directions. The intensity of scattering from a given atoms is dependent largely on the number of electrons, and is represented by the "atomic scattering factor" for the element.
If a periodic array of atoms is present, constructive and destructive interference will result, and we will observe diffraction only in certain directions and for given orientations of the periodic array. Since crystals consist of molecules arranged in a periodic way, a crystal acts as a nearly perfect diffraction grating for electromagnetic radiation in the X-ray region.
There are two basic parts to the study of a crystal by X-ray diffraction. The first is to determine the "where" of diffraction, i.e. the orientations of the crystal and the settings of the detector necessary to observe the diffraction. The information derived in this part of the experiment will yield the unit cell dimensions and symmetry of the crystal, as well as the orientation of this cell on the diffractometer system being used to examine the crystal. Once this information is available, the crystal and detector are systematically repositioned to measure the intensity of diffracted X-rays for each of a finite number of settings. While the number of intensities measured depend on many factors, one will usually try to obtain 100 measurements for each non-hydrogen atom to be located in the structure. While the instrument settings for each of these measurements is determined by the cell size and orientation, the intensity data contains the information necessary to determine the positions of the atoms in the unit cell.
The reason that a straight-forward solution is not possible is that the phase information for each of the measured intensities is not available experimentally (except in some very specialized experiments). While this would appear to be an insurmountable problem, there are many ways to obtain the necessary results. A "trial structure" is obtained by any of several techniques, the most common being "direct methods." Once a trial solution is obtained, additional atoms can be located and the parameters refined until the model agrees with the experimentally measured data.