How to escape an '&' character between brackets in XPath??

R

Ramon F Herrera

I have an XPath expression as follows:

/root/table[@titledetail='Black & White']/detailed

but it is making my XPath programs yell at me.

TIA,

-Ramon
 
A

Alain Ketterlin

Ramon F Herrera said:
I have an XPath expression as follows:

/root/table[@titledetail='Black & White']/detailed

but it is making my XPath programs yell at me.

What's a "XPath program"? If you hide all the details, the best we can
do is use a crystal ball.

XPath doesn't place any restriction on the characters inside a string
literal. If your XPath expression is placed inside an attribute value in
an XML element of a XML document, then usual XML-escaping rules apply,
and & must be written as &

-- Alain.
 
M

Martin Honnen

Ramon said:
I have an XPath expression as follows:

/root/table[@titledetail='Black & White']/detailed

but it is making my XPath programs yell at me.

With XPath that expression should be fine, with XQuery however you need
/root/table[@titledetail='Black & White']/detailed
 
R

Ramon F Herrera

Ramon said:
I have an XPath expression as follows:
/root/table[@titledetail='Black & White']/detailed
but it is making my XPath programs yell at me.

With XPath that expression should be fine, with XQuery however you need
   /root/table[@titledetail='Black & White']/detailed


Thanks, Martin!

With the xqilla CLI, this one works:

xqilla -P -i test.xml q1

where this is the contents of the "q1" file:

/root/table[@titledetail='Black & White']/detailed

The "-P" option:

"-P : Parse in XPath 1.0 compatibility mode (default is XQuery mode)"

-Ramon
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top