XPath (v1) contains no way to encode expressions.
If you only have single OR double quotes then you can use expressions such as
//review[@name=\"Bob
I've had problems with all solutions so far. One has extra text sections (e.g. '"' or "'") which breaks what you're looking for. One drops all text after the last quote/dblquote which breaks as well.
This is a dumb and quick solution from a dumb vb developer:
Function ParseXpathString(ByVal input As String) As String
input = Replace(input, "'", Chr(1))
input = Replace(input, """", Chr(2))
input = Replace(input, Chr(1), "',""'"",'")
input = Replace(input, Chr(2), "','""','")
input = "concat('','" + input + "')"
Return input
End Function
Usage (same as previous examples):
x.SelectNodes("/path[@attr=" & ParseXpathString(attrvalue) & "]")