XML validation code