Passing user input as string to Xpath contains() function

Tag: dom , xslt , xpath Author: liushiguang88 Date: 2013-10-12

Right now I've the below expression to get the word am looking for by going through all the text nodes.In this expression i have given search word inside the function itslef. Every time i cant give the word manually.

//*[contains(text(), \'gremlins\')]'

I need to pass the user input value as string to xpath contains function.Something like this

Var word = "Hello"  
//*[contains(text(), \'that word should come here\')]'

Am new to xpath. Sorry this question may sound stupid.Please help me out

Which programming language are you using?
@Martin Javascript
Are these fragments supposed to be valid JavaScript? The do not look as though they were. How do you code the manual case in JavaScript? Could you show us some concrete code fragment?