String interpreted correct?

Discussion in 'XML' started by Petterson Mikael, Jan 30, 2004.

  1. How can I add a java String variable to an XPath expression?

    Example:

    String parent = "John";
    String query =
    "//Foundation.Core.Class[Foundation.Core.ModelElement.name='"+parent+"']/Foundation.Core.Gene
    ralizableElement.specialization"

    But it gives:


    //Foundation.Core.Class[Foundation.Core.ModelElement.name='John']/Foundation.Core.Gene
    ralizableElement.specialization"

    which will not be interpreted correct by XPath.

    How can I make sure that query is interpreted as:


    //Foundation.Core.Class[Foundation.Core.ModelElement.name="John"]/Foundation.Core.Gene
    ralizableElement.specialization"

    BR

    //Mikael
     
    Petterson Mikael, Jan 30, 2004
    #1
    1. Advertising

  2. Petterson Mikael

    Erwin Moller Guest

    hi,

    try:

    String query =
    "//Foundation.Core.Class[Foundation.Core.ModelElement.name=\""+parent+"\"]/Foundation.Core.GeneralizableElement.specialization";

    use \" if you need a " in a ""-string.

    Regards,
    Erwin Moller
     
    Erwin Moller, Jan 30, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DGW

    Waveform Interpreted

    DGW, Oct 20, 2003, in forum: VHDL
    Replies:
    0
    Views:
    548
  2. Arpan

    Compiled, Not Interpreted!

    Arpan, Nov 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,621
    Karl Seguin
    Nov 25, 2004
  3. Dave Rudolf
    Replies:
    6
    Views:
    1,296
    Mark Thornton
    Jan 14, 2004
  4. Dan Whitaker
    Replies:
    7
    Views:
    528
    kchayka
    Dec 1, 2003
  5. Klaus
    Replies:
    4
    Views:
    339
    Alan Curry
    Aug 25, 2010
Loading...

Share This Page