473,585 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

single quote in xpath

hi,
I've an xml like this..
<REPORT>
<ITEM name="Children' s hospital"/>
<ITEM name="AJ Hospital"/>
</REPORT>

I tried the following xpath to find the node...
XMLDoc.Load (--load above xml--);
string ItemName = "Children's hospital";
System.Xml.XmlN ode ItemNode =
XMLDoc.selectSi ngleNode("//ITEM[@name=' " + ItemName + " ' ")

The above selectsinglenod e statement fails because of the single quote. I
know in MSXML I used to encode the singlequote to &apos;, but it doesnt work
in dotnet. Please let me know how it works in dotnet.

Thanks in advance,
Vivek
Nov 12 '05 #1
1 2533


Vivek wrote:

I've an xml like this..
<REPORT>
<ITEM name="Children' s hospital"/>
<ITEM name="AJ Hospital"/>
</REPORT>

I tried the following xpath to find the node...
XMLDoc.Load (--load above xml--);
string ItemName = "Children's hospital";
System.Xml.XmlN ode ItemNode =
XMLDoc.selectSi ngleNode("//ITEM[@name=' " + ItemName + " ' ")

The above selectsinglenod e statement fails because of the single quote.


You could use
XMLDoc.selectSi ngleNode("//ITEM[@name = \"" + ItemName + "\"")
if you are using C#

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5391
by: Tom Jastrzebski | last post by:
Hi everybody, How to escape a single quote in java 1.5 javax.xml.xpath XPath queries? Eg. meta I have tried numerous approaches that typically work but none of them did. Does anybody KNOW how to do it? Thanks in advance. Tom
3
5818
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 characters (including &quot; and &apos;) I have java code using Xerces to select a node based on it's @OID attribute using an XPath like this:
2
14431
by: girish | last post by:
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: //*
2
3018
by: Joe Gass | last post by:
I have an xml doc <sections> <section> <title>entry image</title> </section> <section> <title>22'2</title> </section> </sections>
4
31205
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"> </Authors>
2
7429
by: Christian Rühl | last post by:
heyho, guys! here's another question for you now: i built an iterator to get all the nodes with a certain attribute in an xml dom. it all looks like this (i'm using .NET framework 1.1) string xpath;
8
21475
by: Marina Levit [MVP] | last post by:
I've scoured google, but apparently none of the suggestions actually work. I have the following. type of XPATH query "SomeNode[SomeAttribute = 'abc's search'" Now, I've tried doing this: "SomeNode[SomeAttribute = 'abc@apos;s search'"
3
3603
by: PT | last post by:
Hi, I've a simple XML tree that is essentially. <?xml version="1.0"?> <Project> <Version Version="1.001" /> <Platform Name="Platform1"/> <Platform Name="Platform2" /> </Project>
0
1917
by: apurvaG | last post by:
Hi All, .net is giving me error if my X-path has a singlequote. Following are the details XML Used : <emp> <emp.fname>o'brian</emp.fname> <emp.lname>walls</emp.lname>
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8336
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3835
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
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 we have to send another system
1
1447
muto222
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.