By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

XPath for attributes with single and double quotes

P: n/a
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

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <bd******************************@news.thenewsgrou ps.com>,
girish <gi***********@mail.forum4designers.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
Jul 20 '05 #2

P: n/a
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_
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.