Marina Levit [MVP] wrote:
Quote:
I've scoured google, but apparently none of the suggestions actually work.
>
I have the following. type of XPATH query
>
"SomeNode[SomeAttribute = 'abc's search'"
>
Now, I've tried doing this:
>
"SomeNode[SomeAttribute = 'abc@apos;s search'"
>
and I've tried
>
"SomeNode[SomeAttribute = 'abc@quot;s search'"
>
And neither one of these gives me a result.
>
Note, because of the structure and the way this XPATH is put together, I
would prefer to not have to use double quotes as the delimiters for the
search string, I'd like to keep it single quotes.
>
How to make this query find my node?
In what context are you using the XPath? If that is an XSLT stylesheet
then using entity references like ' or " might help but if you
have .NET code (e.g. C# or VB.NET) then using those XML entity
references is not possible.
As for that escape problem, it is ugly, XPath 1.0 itself does not have
any escape mechanism so you need to split strings e.g. C# string literal
to be passed to SelectSingleNode looks like
@"SomeNode[@SomeAttribute = concat('abc', ""'"", 's search')]"
See also Oleg's blog
<http://www.tkachenko.com/blog/archives/000627.htmlrespectively the
XPathCache API the MVP XML project provides.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/