473,794 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.SelectSingl eNode"/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 3004
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.SelectSingl eNode"/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.SelectSingl eNode"/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.SelectSingl eNode"/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.SelectSingl eNode("/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.SelectSingl eNode"/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.SelectSingl eNode("/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
1203
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 general consensus on how to proceed from here. Thank you in advance for anyone who takes the time to reply... I am upgrading a VB4.0 program for a client who distributes it to its reps worldwide. We are not at the point where we want to make...
3
3975
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 "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/urllib.py", line 1117, in quote res = map(safe_map.__getitem__, s)
4
2195
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. I've got a simple program here (I actually found it on the web somewhere, but I'm looking through it) that doesn't seem to have that ending quote at when it gets down to the end. In this program it doesn't make much of a difference, but I've...
8
1395
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 reguister with email address and password if password is lost
10
3027
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
2796
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 free. Ajax based solution refreshes data at configured time interval and you don't have to wait for your favourite stock to appear in ticker. You have all latest view auto updated and for all the stocks at one go. In my approach i am using ajax...
4
2224
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 single-quoted string". How can Python claim it scanned a single-quoted string when I fed it with a double-quoted string? Is quote type (single quote and double quote) recognition not implemented in Python?
3
1526
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 have to parse the single quote strings from inside s. Is there an existing string quote parser which I can use or should I write a parser myself?
9
4563
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. Please Help <? $filename = "whatsnew.txt"; # file to read if (file_exists($filename)) {
0
9671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.