How to check xml file is valid or not and have any special characters and space

can any one tell me regarding this issue

how can i check xml file is valid or not and any special character and any space

once if the file have any special characters it will be show some message box like

have some space and special characters .............