Below is xml file format from which words to be searched.
<Book>
<Page id="1">
<Head>Preface</Head>
<Body>
<Paragraph>
<Line>
<Word>
<Char>T</Char>
<Char>h</Char>
<Char>i</Char>
<Char>s</Char>
</Word>
<Word>
<Char>-</Char>
</Word>
<Word>
<Char>i</Char>
<Char>s</Char>
</Word>
<Word>
<Char>-</Char>
</Word>
<Word>
<Char>s</Char>
<Char>a</Char>
<Char>m</Char>
<Char>p</Char>
<Char>l</Char>
<Char>e</Char>
</Word>
<Word>
<Char>-</Char>
</Word>
<Word>
<Char>t</Char>
<Char>e</Char>
<Char>x</Char>
<Char>t</Char>
</Word>
</Line>
</Paragraph>
</Body>
</Page>
I used the below XPath expressions in C# to find values of Char Node.
XmlDocument objXmlDoc = new XmlDocument();
XmlNodeList objXmlNodeList;
objXmlDoc.Load(sFilePath);
objXmlNodeList = objXmlDoc.SelectNodes("//CHAR[translate(text(),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')='" + txtFindText.Text.ToUpper() + "']");
Here, how to get a complete word with XPath from above XML File ?
It is not possible theoretically. The reason is that XML/XPATH does not ensure order as the result of a query is a “node-set” which by definition is “an unordered collection of nodes without duplicates”.
http://www.w3.org/TR/xpath/
Nevertheless, you can get close to the requirement. For example, you can get the first word: