Xpath containing '

R

Robert Mago

How do you evaluate an xpath in c# containing a ' ? I tried using ' but
it did not work

Thanks
 
M

Martin Honnen

Robert said:
How do you evaluate an xpath in c# containing a ' ? I tried using ' but
it did not work

A single quote should not pose a problem e.g.
xmlDocument.SelectSingleNode(@"//p[@id = 'p1']")
It only becomes difficult if you want to write a string literal
containing single and double quotes, then you have to break up the
string and use concat e.g.
xmlDocument.SelectSingleNode("@//p[contains(., concat('""', ""Kibo's
email"", '""'))]")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top