HighTechTalks DotNet Forums  

Re: XPath-syntax: referencing node with " in attribute-value

Dotnet XML microsoft.public.dotnet.xml


Discuss Re: XPath-syntax: referencing node with " in attribute-value in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Oleg Tkachenko [MVP]
 
Posts: n/a

Default Re: XPath-syntax: referencing node with " in attribute-value - 10-28-2007 , 06:02 AM






References: <eDCnW78FIHA.5272 (AT) TK2MSFTNGP05 (DOT) phx.gbl> <#9rXqQ9FIHA.4684 (AT) TK2MSFTNGP06 (DOT) phx.gbl>
In-Reply-To: <#9rXqQ9FIHA.4684 (AT) TK2MSFTNGP06 (DOT) phx.gbl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <O$NHGnUGIHA.1188 (AT) TK2MSFTNGP04 (DOT) phx.gbl>
Newsgroups: microsoft.public.dotnet.xml
NNTP-Posting-Host: 62-90-13-82.barak.net.il 62.90.13.82
Path: border1.nntp.dca.giganews.com!nntp.giganews.com!ne wshub.sdsu.edu!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.p hx.gbl
Lines: 27
Bytes: 1824
X-Original-Lines: 1
Xref: number1.nntp.dca.giganews.com microsoft.public.dotnet.xml:35478

Martin Honnen wrote:
Quote:
Daniel Barisch wrote:

Within attribute-values i can use the double quote, which is written
automaticly
as "&quot;" into the document by the XML-methods of .NET:
Node Name="a&quot;b" Att1="true"/

But how to reference such nodes with an XPath-expression?
=> pXml.SelectSingleNode("//Folder[@Name=??]")

What's the correct Syntax?

With C# you can use
pXml.SelectSingleNode("//Node[@Name = 'a\"b']")
With VB.NET you can use
pXml.SelectSingleNode("//Node[@Name = '\""b']")

The real problem only occurs if the attribute value contains single
_and_ double quotes. In that case you would need to break up the string
into components.
And even for that problem there is a solution, such as using variables.
Here is a sample - http://www.tkachenko.com/blog/archives/000385.html

--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.