xpath to get Node containing text

Since you need all textNodes only which contain the text Yahoo, use the following XPath.

//text()[contains(., 'Yahoo')]

This should return you all the textNodes only which contains Yahoo (case-sensitive) in it.


Your XML is malformed. </content></doc></story> should be </content></story></doc>.

Apart from that, the XPath you would want is

/doc/story/content//*[contains(., 'Yahoo')]

(select any descendant of <content> which contains the text "Yahoo" -- this will select the <p>)