473,388 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

XML and quote

This is my XML file

<?xml version="1.0" encoding="utf-8"?>
<index>
<folder Name="Test1">
<folder Name="Test2">
<files>
<file Name="After You've Gone.mp3"/>
<file Name="Prova.mp3"/>
</files>
</folder>
</folder>
</index>
nodeSel = doc.SelectSingleNode"/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name='After You've Gone.mp3']");
and this function make me error, to token not valid

I think the problem is the quote in : "After You've Gone.mp3"
how have to do ?
Thank you

Marco

May 8 '07 #1
4 2988
mtugnoli wrote:
This is my XML file

<?xml version="1.0" encoding="utf-8"?>
<index>
<folder Name="Test1">
<folder Name="Test2">
<files>
<file Name="After You've Gone.mp3"/>
<file Name="Prova.mp3"/>
</files>
</folder>
</folder>
</index>
nodeSel = doc.SelectSingleNode"/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name='After You've Gone.mp3']");
and this function make me error, to token not valid

I think the problem is the quote in : "After You've Gone.mp3"
how have to do ?
Thank you

Marco
Hi, Marco,

use ' is &apos;

Regards,
Petar Atanasov
http://a-wake.net
May 8 '07 #2
On 8 Mag, 17:05, Petar Atanasov <ppa_i...@mail.bgwrote:
mtugnoli wrote:
This is my XML file
<?xml version="1.0" encoding="utf-8"?>
<index>
<folder Name="Test1">
<folder Name="Test2">
<files>
<file Name="After You've Gone.mp3"/>
<file Name="Prova.mp3"/>
</files>
</folder>
</folder>
</index>
nodeSel = doc.SelectSingleNode"/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name='After You've Gone.mp3']");
and this function make me error, to token not valid
I think the problem is the quote in : "After You've Gone.mp3"
how have to do ?
Thank you
Marco

Hi, Marco,

use ' is &apos;

Regards,
Petar Atanasovhttp://a-wake.net- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -


this time the error don't occour but the node is not found ...

"/index/folder[@Name='Test1']/folder[@Name='Test2']/files/
file[@Name='After You&apos;ve Gone.mp3']"
May 8 '07 #3
mtugnoli wrote:
This is my XML file

<?xml version="1.0" encoding="utf-8"?>
<index>
<folder Name="Test1">
<folder Name="Test2">
<files>
<file Name="After You've Gone.mp3"/>
<file Name="Prova.mp3"/>
</files>
</folder>
</folder>
</index>
nodeSel = doc.SelectSingleNode"/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name='After You've Gone.mp3']");
Unfortunately that is difficult to achieve with XPath 1.0 as it does not
allow you to escape characters, rather all it allows is breaking up the
string into sequences you concatenate e.g.
doc.SelectSingleNode("/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name= concat('After You', \"'\", 've
Gone.mp3')]")
Thus if someone passes you the @Name value as a string you will have to
write code with C# that breaks up the string into pieces not containing
single quotes and containing single quotes to convert into one string
that uses the XPath concat function to concatenate pieces delimited by
single quotes with pieces delimited by double quotes as in the above
example.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 8 '07 #4
Martin Honnen wrote:
mtugnoli wrote:
>This is my XML file

<?xml version="1.0" encoding="utf-8"?>
<index>
<folder Name="Test1">
<folder Name="Test2">
<files>
<file Name="After You've Gone.mp3"/>
<file Name="Prova.mp3"/>
</files>
</folder>
</folder>
</index>
nodeSel = doc.SelectSingleNode"/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name='After You've Gone.mp3']");

Unfortunately that is difficult to achieve with XPath 1.0 as it does not
allow you to escape characters, rather all it allows is breaking up the
string into sequences you concatenate e.g.
doc.SelectSingleNode("/index/folder[@Name='Test1']/
folder[@Name='Test2']/files/file[@Name= concat('After You', \"'\", 've
Gone.mp3')]")
Thus if someone passes you the @Name value as a string you will have to
write code with C# that breaks up the string into pieces not containing
single quotes and containing single quotes to convert into one string
that uses the XPath concat function to concatenate pieces delimited by
single quotes with pieces delimited by double quotes as in the above
example.

Thanks Martin,
I usually “guard” my code in the C#, but this technique seems more
effective.

Regards,
Petar Atanasov
http://a-wake.net
May 9 '07 #5

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

Similar topics

1
by: jmar | last post by:
I posted on this topic a while back and received some good responses. However, I have better insight into what I'm looking to do so I am tapping the wealth of experience here again hoping to find a...
3
by: nyenyec | last post by:
urllib.quote chokes on unicode in 2.4.4. 2.4.4 (#1, Oct 18 2006, 10:34:39) Traceback (most recent call last): File "<stdin>", line 1, in ? File...
4
by: wesbland | last post by:
>From my understanding, when a string is stored in VB.NET and you look at it in the debugger, it has a quote on both sides to signify that it is a string as opposed to a char or int or whatever. ...
8
by: plemon | last post by:
alright here is what it is: a computer site where customers build custom system by selecting from forms and radio buttons. what is needed: a database (MySQL) with php basicly... 1 users...
10
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
How can I use a quote as a literal so it does get confused as not a literal? Thanks! Bob
3
by: Rajesh | last post by:
Have you guys wanted to have stock tickers on ur desktop/ web pages, but can't use applets as they were heavy, too much configuration than here is one approach and light weight solution all for...
4
by: wxPythoner | last post by:
There's a thing that bugs me in Python. Look at this... SyntaxError: EOL while scanning single-quoted string Please focus on the part of the error message that states "while scanning...
3
by: rajmohan.h | last post by:
Hi all, Suppose I have a string which contains quotes inside quotes - single and double quotes interchangeably - s = "a1' b1 " c1' d1 ' c2" b2 'a2" I need to start at b1 and end at b2 - i.e. I...
9
by: WebArchitect | last post by:
I have a text file. My text file contains lines with double quotes around it. I trying to code if a line has double quotes around it Then make it bold My code is below and it is not working....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.