What kind of validation? Do you mean parsing XML documents against a DTD or XSD file?
For XSD validation it's actually not that hard. You first use SchemaFactory to create a Schema.
Next you create a DocumentBuilderFactory or SAXParserFactory, set the Schema and set validating on.
Next you use the DocumentBuilderFactory to create a DocumentBuilder, or the SAXParserFactory to create a SAXParser.
Finally, you use the DocumentBuilder or SAXParser to parse the XML document.
xhtml is infinitely "extensible", in essence, by the x itself so named. I suppose you don't mean you've your own custom module extending the base of it?... xhtml validation is no difference from validating any schema/DTD backed xml document and the outline of how to do it is already pointed out.
If you mean you are not yet very agile in doing validating xml, I would say you can use many validating service out there such as this or any other you might come across after by googling.
http://validator.w3.org/#validate_by_input You can cut-and-paste the "string" for the purpose or you can use the variation of validating via a url...