Groups | Blog | Home
all groups > dotnet xml > april 2005 >

dotnet xml : single quote in xpath


Martin Honnen
4/8/2005 12:00:00 AM


[quoted text, click to view]


[quoted text, click to view]

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

--

Martin Honnen --- MVP XML
Vivek
4/8/2005 10:03:14 AM
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.XmlNode ItemNode =
XMLDoc.selectSingleNode("//ITEM[@name=' " + ItemName + " ' ")

The above selectsinglenode 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

AddThis Social Bookmark Button