Is it possible to validate a CAML query (to check whether it is correctly formed or not) before executing it in SharePoint? Otherwise, while executing the CAML query, it gives weird errors, which don't give any indication that, it is because of the improper CAML query.
A great tool to use to craft, test, and validate is the BIWUG CAML Designer. It can be found on their web site, http://www.biwug.be/resources. It has been highly invaluable when working with both client side and server side code.