I tried to search for nodes containing text \'Yahoo\' under \'/doc/story/content\', it returns \'content\' node, but I need exact text node that contains \'Yahoo\' or it\'s
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>
)