Here is my Xpath:
path="form/document[contains(type, '<%= request.Form("txtSearch")%>')]//*";
Let's be clear. That is not an XPath expression. It is (ASP|JSP|PHP)-like code for generating an XPath expression.
To search for a string appearing in any text node descendant of the <document> element (but not crossing element boundaries), and to return the immediately containing elements, you could use the XPath expression
form/document//*[contains(text(), '......')]
and of course you could generate that from (ASP|JSP|PHP) in the same way.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference