> Here is a sample of code I was using before that also works when a ' is > replaced with `.
Yah, cause a backtick isn't magical in the world of XPath. It's just another byte, basically. Single- and double-quotes delimit string literals. In your original example, you're creating a single-quote string literal as the attribute value. If instead you did double-quote string literals, then things with single-quotes would pass just fine: new XPath( "CD/artist[@name=\"" + artist + "\"]" ); Of course, that would then flake out on anything with a double-quote in the value. > Here is the fix to my problem. It properly handles ' in names of the > strings set in the SimpleVariableContext. Will this work for other > characters that might invalidate xpath syntax? Yes, because all of the problems you've seen so far occur at the lexical level. Using $variable notation, you're bypassing the lexer with your value. That value only gets dealt with at evaluation time, and *not* at lex-time. The lexer only sees "$variable" which is always legal. You should see no problem even if you set $artist to the string "foo/bar<baz><cheese@'\"". It's opaque, and is never lexed. > XPath xpathArtist = new XPath(strXPathArtist); > XPath xpathAlbum = new XPath(strXPathAlbum); > XPath xpathTract = new XPath(strXPathTract); > > xpathArtist.setVariableContext(variables); > xpathAlbum.setVariableContext(variables); > xpathTract.setVariableContext(variables); This looks like a good candidate for someone to write a ChainedXPath container, or something. XPath xpathArtist = new ChainedXPath( strXPathArtist ); XPath xpathAlbum = xpathArtist.append( "album[@title=$album]" ); XPath xpathTrack = xpathAlbum.append( "track[@title=$track]" ); Of course, that'd just evaluate each segment in order, using the results as the context of the next link in the chain. Might be sub-optimal. -bob _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest