A general least-squares technique for X-ray diffraction line broadening analysis has been developed. The technique can be used to determine single, double, and triple line broadening effects caused by small particle sizes, microstrain, stacking faults, or all three presented in a closed-packed hexagonal nanomaterial. The technique was applied to characterize the microstructure of β-Ni(OH)2, a negative electrode material in nickel-metal hydride (NiMH) batteries. Double line broadening effects caused by both small crystallite sizes and stacking faults in β-Ni(OH)2 were detected and analyzed. Triple line broadening effects caused simultaneously by small crystallite sizes, microstrain, and stacking faults were detected in β-Ni(OH)2 after activation and charge-discharge cycle tests. The triple line broadening effects were found to be selective and most pronounced for diffraction lines with h−k=3n±1. The broadening effects were larger when l=even, but smaller when l=odd. The shape and the average size of the crystallites, microstrain, and stacking fault probability in β-Ni(OH)2 changed dramatically after activation and charge-discharge cycles. The method was also applied to characterize and investigate the microstructure of nano ZnO materials. Results indicate that no selective broadening appears in the XRD patterns of the nano ZnO materials. The average crystallite sizes were different slightly, and the stacking fault probabilities differed significantly with different dopants.