I am parsing an xml file and run into a problem when trying to find a node that has an apostrophe in it. When the element name does not have this, everything works fine. I tried replacing the apostrophe with different escape characters, but I was not very lucky
string s = "/itemDB/item[@name='" + itemName + "']";
// Things i have tried that did not work
// s.Replace("'", "''");
// .Replace("'", "\'");
XmlNode parent = root.SelectSingleNode(s);
I always get an XPathException. What is the right way to do this. Thanks
source
share