XRD by itself can not used to measure sample porosity (it only identifies crystalline phases/structures in the sample)... It can be used to determine the theoretical density of the phases present in the sample as given above or from the XRD file for the identified phase. The sample density has to be measured independently to estimate porosity.
XRD can be used to estimate particle size of powders by line broadening.