Re: [xsl] How to select for ' in XPATH?

Subject: Re: [xsl] How to select for ' in XPATH?
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Wed, 5 Aug 2009 22:30:06 +0200
> Should be using the apostrophe attribute delimiter and double
> quote string delimiter:
>    '//*[contains(., "What&#x27; that?")]'

Here the 's' is missing, should be
     '//*[contains(., "What&#x27;s that")]'

I removed the question mark in order to apply that xpath to the
following old post in xsl-list archive (containing "What's that ..."):

Below you find a "xpath" bookmarklet which allows you and others to
easily play around with xpath searches on any webpage with Firefox.
1) go to some webpage
2) click on the "xpath" bookmark    (install instructions below)
3) enter any xpath into the dialog
4) click "OK"
5) all DOM nodes matched by the xpath get marked by blue rectangles
6) displays "Found n matches for xpath(xyz)" in browser status bar

And these are the results on above mentioned link:
  Found 4 matches for xpath(//table)
  Found 1 match for xpath(//h2)
  Found 1 match for xpath(/*/*/*[contains(.,"What")])
  Found 0 matches for xpath(/*/*/*[contains(.,"What&x27;")])

Happy xpath matching!
And hopefully someone finds the correct apostroph match that way ...

The bookmarklet works for Firefox web browsers.
1) create a bookmark named "xpath"
2) open the properties of that bookmark
3) copy and paste the complete bookmarklet below into "Location"
4) click OK.

In case the email gateway adds "interesting" characters to this post,
the complete bookmarklet can be downloaded under this link, too:


  var count=0, text, e;
  xpath=prompt("xpath()", "");
  if(xpath==null || xpath.length==0)

  var nodesSnapshot = document.evaluate(xpath, document.body, null,
                        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );

  for ( var i=0 ; i < nodesSnapshot.snapshotLength; i++ )
    e = nodesSnapshot.snapshotItem(i);"solid";"2px";"blue";;


  window.status="Found "+count+" match"+(count==1?"":"es")
               +" for xpath("+xpath+")";

Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler
WebSphere DataPower SOA Appliances
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

             "G. Ken Holman"                                               
   >                                             To 
             08/05/2009 09:23                                           cc 
                                       Re: [xsl] How to select for &apos;  
             Please respond to         in XPATH?                           

I rushed my answer and made a mistake.

At 2009-08-05 12:16 -0700, I wrote:
>In XSLT 1:
>   "//*[contains(., 'What&#x27; that?)]"

Should be using the apostrophe attribute delimiter and double quote
string delimiter:

    '//*[contains(., "What&#x27; that?")]'

Sorry for misleading you.

. . . . . . . . . ken

Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread