To check validity you pass the document through a validating parser which should report any errors it finds. For example,
% java sax.SAXCount -v invalidhotcop.xml Error at (file file:/D:/speaking/SD99EAST/dtds/invalidhotcop.xml, line 10, char 8): Element "<SONG>" is not valid because it does not follow the rule, "(TITLE,C OMPOSER+,PRODUCER*,PUBLISHER*,LENGTH?,YEAR?,ARTIST+)". invalidhotcop.xml: 281 ms
A valid document:
% java sax.SAXCount -v validhotcop.xml validhotcop.xml: 170 ms