Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to escape an '&' character between brackets in XPath??

Reply
Thread Tools

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

 
 
Ramon F Herrera
Guest
Posts: n/a
 
      06-15-2012

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
 
Reply With Quote
 
 
 
 
Alain Ketterlin
Guest
Posts: n/a
 
      06-15-2012
Ramon F Herrera <(E-Mail Removed)> writes:

> 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 &amp;

-- Alain.
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-15-2012
Ramon F Herrera wrote:
>
> 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 &amp; White']/detailed


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/


 
Reply With Quote
 
Ramon F Herrera
Guest
Posts: n/a
 
      06-15-2012
On Jun 15, 5:28*am, Alain Ketterlin <(E-Mail Removed)-strasbg.fr>
wrote:
> Ramon F Herrera <(E-Mail Removed)> writes:
>
> > 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 an "XPath program"?


(1) The XQuilla library is an example.

(2) Stylus Professional is another.

Both reject the syntax in question.

-Ramon

 
Reply With Quote
 
Ramon F Herrera
Guest
Posts: n/a
 
      06-15-2012
On Jun 15, 5:46*am, Martin Honnen <(E-Mail Removed)> wrote:
> Ramon F Herrera wrote:
>
> > 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 &amp; 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to read strings cantaining escape character from a file and useit as escape sequences? slomo Python 5 12-02-2007 11:39 AM
what is the difference between the two kinds of brackets? narutocanada@gmail.com Python 10 10-22-2007 02:58 AM
ASCII file parser - to read between brackets () olson_ord@yahoo.it C++ 9 02-16-2006 09:00 AM
Spaces in between brackets semmons99@gmail.com Ruby 5 02-03-2006 02:07 PM



Advertisments