How to write an xpath to select a node whose text contains special characters such as ' which is kind of invalid inxpath?
<Nodes><Node><Text>General Marketing'</Text><Nodes><Node><Text>Brochures</Text></Node><Node><Text>Value-Added</Text><Nodes><Node><Text>About Henderson</Text></Node><Node><Text>Own the World</Text></Node></Nodes></Node></Nodes></Node></Nodes>
and
var branchName = "General Marketing'";
var xPath = String.Format("/Nodes/Node[Text = '{0}']", branchName);
the above xpath fails because the xPath contains the below text:
/Nodes/Node[Text = 'General Marketing'']
As you can see there are 2 apostorophes.
From my tests so far it only has problem with '. Not sure whether there are any other special characters that it may have issue with?
So I guess I'd need to modify my xpath to be something else.
I tried the below but didn't work:
var xPath = String.Format("/Nodes/Node[Text = \"{0}\"]", branchName);
Hope the question is clear.
Thanks,