XPath for attributes with single and double quotes

Discussion in 'XML' started by girish, Aug 4, 2004.

  1. girish

    girish Guest

    In my XML document, some node attributes data contains both single quot
    and double quote characters, such as

    <input msg="Hello "World", What's up"/>.

    The double quotes are in form of escape sequence in the XML document.
    am not able to locate such elements using an XPath expression. I trie
    the following:

    //*[@msg="Hello "World", What's up"]
    Failes with string error at double quote before World

    //*[@msg='Hello "World", What's up']
    Failes with string error at single quote after What

    //*[@msg="Hello "World", What's up"]
    I used the escpase sequence for double quote in my xpath which you ar
    seeing as acutal double quote in this post.
    No Error but does not return any node.

    //*[@msg="Hello "World", What's up"]
    I used the escpase sequence for both double quotes and single quotes i
    my xpath which you are seeing as acutal double quote and single quotesi
    this post
    No Error but does not return any node

    I tried both MSXML 3.0 and MSXML 4.
    Any Ideas?
    -
    giris
    -----------------------------------------------------------------------
    Posted via http://www.forum4designers.co
    -----------------------------------------------------------------------
    View this thread: http://www.forum4designers.com/message103989.htm
     
    girish, Aug 4, 2004
    #1
    1. Advertising

  2. In article <>,
    girish <4designers.com> wrote:

    >In my XML document, some node attributes data contains both single quote
    >and double quote characters

    [...]
    >I am not able to locate such elements using an XPath expression.


    Yes, annoying isn't it. You can't write an XPath string literal
    that contains both kinds of quote.

    You can construct the string by breaking it into pieces that use only
    one kind of quote, and concatenating them using concat:

    //*[@msg=concat('Hello "World", What', "'s up")]

    If you're using this expression in a XML attribute (e.g. in an XSLT
    stylesheet) you'll still need to escape whichever kind of quote is
    used for the attribute value.

    -- Richard
     
    Richard Tobin, Aug 4, 2004
    #2
    1. Advertising

  3. girish

    Peter Flynn Guest

    girish wrote:

    > In my XML document, some node attributes data contains both single quote
    > and double quote characters, such as
    >
    > <input msg="Hello "World", What's up"/>.
    >
    > The double quotes are in form of escape sequence in the XML document. I
    > am not able to locate such elements using an XPath expression. I tried
    > the following:
    >
    > //*[@msg="Hello "World", What's up"]
    > Failes with string error at double quote before World
    >
    > //*[@msg='Hello "World", What's up']
    > Failes with string error at single quote after What
    >
    > //*[@msg="Hello "World", What's up"]
    > I used the escpase sequence for double quote in my xpath which you are
    > seeing as acutal double quote in this post.
    > No Error but does not return any node.
    >
    > //*[@msg="Hello "World", What's up"]
    > I used the escpase sequence for both double quotes and single quotes in
    > my xpath which you are seeing as acutal double quote and single quotesin
    > this post
    > No Error but does not return any node
    >
    > I tried both MSXML 3.0 and MSXML 4.
    > Any Ideas??


    &quot; is your friend.

    ///Peter
    --
    "The cat in the box is both a wave and a particle"
    -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
     
    Peter Flynn, Aug 6, 2004
    #3
    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. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,897
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,719
    Oisin
    Mar 24, 2006
  3. Sydex
    Replies:
    12
    Views:
    6,601
    Victor Bazarov
    Feb 17, 2005
  4. Stephan Kämper
    Replies:
    1
    Views:
    184
  5. jOhn
    Replies:
    1
    Views:
    252
    Phlip
    Jan 29, 2008
Loading...

Share This Page