<p>How can I use XPath to select an XML-node based on its content? </p>

<p>If I e.g. have the following xml and I want to select the &lt;author&gt;-node that contains Ritchie to get the author's full name:</p>

<pre><code>&lt;books&gt;
    &lt;book isbn='0131103628'&gt;
        &lt;title&gt;The C Programming Language&lt;/title&gt;
        &lt;authors&gt;
            &lt;author&gt;Ritchie, Dennis M.&lt;/author&gt;
            &lt;author&gt;Kernighan, Brian W.&lt;/author&gt;
        &lt;/authors&gt;
    &lt;/book&gt;
    &lt;book isbn='1590593898'&gt;
        &lt;title&gt;Joel on Software&lt;/title&gt;
        &lt;authors&gt;
            &lt;author&gt;Spolsky, Joel&lt;/author&gt;
        &lt;/authors&gt;
    &lt;/book&gt;
&lt;/books&gt;
</code></pre>

[{'answer_id': 30019, 'author': 'Cros', 'author_id': 1523, 'author_profile': 'https://Stackoverflow.com/users/1523', 'pm_score': 2, 'selected': False, 'text': '<p>The XPath for this is: </p>\n\n<pre><code>/books/book/authors/author[contains(., \'Ritchie\')]\n</code></pre>\n\n<p>In C# the following code would return "Ritchie, Dennis M.":</p>\n\n<pre><code>xmlDoc.SelectSingleNode("/books/book/authors/author[contains(., \'Ritchie\')]").InnerText;\n</code></pre>\n'}, {'answer_id': 30021, 'author': 'Chris Marasti-Georg', 'author_id': 96, 'author_profile': 'https://Stackoverflow.com/users/96', 'pm_score': 2, 'selected': False, 'text': "<pre><code>//author[contains(text(), 'Ritchie')]\n</code></pre>\n"}, {'answer_id': 30023, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 6, 'selected': True, 'text': "<pre><code>/books/book/authors/author[contains(., 'Ritchie')]\n</code></pre>\n\n<p>or</p>\n\n<pre><code>//author[contains(., 'Ritchie')]\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/30018', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1523/']