XML with XPath in C# (handling apostrophe (‘) character)

Posted on May 27, 2008. Filed under: XML | Tags: , , , , |

The other day I was coding in C# to get a XML node based on its attributes value:
string sUser = “U1″;
XmlNode xnUser =
xmlDocument.SelectSingleNode(“tm:TM/tm:Admin/tm:User[@ID='" + sUser + "']“, TMNamespaceManager);
Now the good thing is it works in most cases but as soon as the sUser contains an apostrophe character the above code fails.
So I decided to do [...]

Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...