Since the provided "XML" is not a well-formed document due to nested apostrophes, the XPath expression cannot be evaluated on it .
The provided incorrectly formed text can be corrected for:
<img src="somelink" border="0" alt="commission:Alfred misadventures" title="commission:Alfred misadventures"/>
If there is a strange requirement not to use quotation marks, then one correct conversion :
<img src='somelink' border='0' alt='commission:Alfred's misadventures' title='commission:Alfred's misadventures'/>
If you are provided with incorrect input, in a language such as C #, you can try to convert it to its correct instance using :
string correctXml = input.replace("\\'s", "'s")
Perhaps there is a similar way to do the same in Python.
Dimitre novatchev
source share