VariableContext variables = new SimpleVariableContext();
context.setVariableValue( "", "name", "Here's Johnny" );


XPath xpathArtist = new XPath("//a[@n=$name]");
xpathArtist.setVariableContext( variables );

...

James
----- Original Message -----
From: "Jason Long" <[EMAIL PROTECTED]>
To: "Jaxen-Interest" <[EMAIL PROTECTED]>
Sent: Wednesday, October 31, 2001 8:15 PM
Subject: [Jaxen] Escaping ' and " in xpath strings


>
> Could you please give me an example of how to do I do this using jaxen?
> I have used this with XSL, but never from java code.
>
> --------------------------------------------------------------------------
--
> --
> James wrote:
>
> You could use XPath variables to get around this. Then your XPath
expression
> could be
>
> //a[@n=$str]
>
> Then you could create a VariableContext and put any old string containing
> any number of quote characters.
>
> James
> ----- Original Message -----
> From: "Jason Long" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 31, 2001 7:13 PM
> Subject: [Jaxen] Escaping ' and " in xpath strings
>
>
> > I have been working on an application that uses both jdom and jaxen.
> >
> > Here is and example of my problem?
> >
> > String str = "Johnny's Dinner";
> > XPath xpathArtist = new XPath("//a[@n='" + str + "']");
> >
> > I read somewhere that replacing ' with "'" or " with '"'.
> >
> > Is this the best way to do this?
> > Is there support built into jaxen to clean up string prior to being used
> in
> > XPath?
> >
> > Best Regards,
> >
> > Jason Long
> > JML Internet Enterprises - www.jmlie.com
> > BS Physics, MS Chemical Engineering
> >
> >
> > _______________________________________________
> > Jaxen-interest mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jaxen-interest
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to