473,473 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

XPath for attributes with single and double quotes

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
2 14391
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
1
by: Alastair Cameron | last post by:
VB6, MSXML 3.2 installed: Q1. I am having a problem selecting nodes with XPATH expressions when an attribute values contain backslashes (\\) in as part of its value: For example the...
3
by: Kevin | last post by:
I know this has probably been discussed many times before (I found answers when I searched yesterday), but I still can't get it to work... I have an attribute @OID that can contain any...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
2
by: Matthew Wieder | last post by:
Does someone have the routine (preferablly in C#) that takes a string (i.e. "3995 Joseph, Smith "Joe") and prepares it for use in an XPath query ( i.e. SelectSingleNode(/member) ) so that all...
7
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
4
by: Justin Fancy | last post by:
Hi everyone, I need to replace all instances of a double quote(") with two single quotes('') in a text file. I already have some replacements of strings going on, but I tried this one, but the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.