473,387 Members | 1,379 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,387 software developers and data experts.

Working With Ampersands

How does one allow the use of ampersands (or other special characters
for that matter) within Element text and Attribute text?

I have problems using LoadXml from a string "<text value="Jack &
Jill"/>" into an XmlDocument.

I can't for the life of me find a switch that turns off this feature of
the parser.

-AJ
Nov 12 '05 #1
5 6468
AJ Brown wrote:
How does one allow the use of ampersands (or other special characters
for that matter) within Element text and Attribute text?

I have problems using LoadXml from a string "<text value="Jack &
Jill"/>" into an XmlDocument.
& in XML must be escaped as &amp;. And < must be escaped as &lt;
I can't for the life of me find a switch that turns off this feature of
the parser.


There is no such one. It's a must.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
no switch. this part of the xml spec. You must either:
encode/escape the ampersand (and other special characters).
dlr

"AJ Brown" <aj*****************@hotmail.com> wrote in message
news:s9LSc.16242$Yf6.15006@lakeread03...
How does one allow the use of ampersands (or other special characters
for that matter) within Element text and Attribute text?

I have problems using LoadXml from a string "<text value="Jack &
Jill"/>" into an XmlDocument.

I can't for the life of me find a switch that turns off this feature of
the parser.

-AJ

Nov 12 '05 #3
If you use DOM methods to put the data into the document then the escaping and unescaping will be
done for you.

Using string concatenation and the like forces you to read and adhere to the specs very carefully to
ensure validity of the resultant document (eg. '<' becomes '&lt;' etc.).

Chris.

"AJ Brown" <aj*****************@hotmail.com> wrote in message
news:s9LSc.16242$Yf6.15006@lakeread03...
How does one allow the use of ampersands (or other special characters
for that matter) within Element text and Attribute text?

I have problems using LoadXml from a string "<text value="Jack &
Jill"/>" into an XmlDocument.

I can't for the life of me find a switch that turns off this feature of
the parser.

-AJ
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004
Nov 12 '05 #4
> How does one allow the use of ampersands (or other special characters for
that matter) within Element text and Attribute text?

I have problems using LoadXml from a string "<text value="Jack & Jill"/>"
into an XmlDocument.

I can't for the life of me find a switch that turns off this feature of
the parser.
Because you can't. There 5 characters that MUST be encoded when used in
XML.

& - &amp;
< - &lt; - &gt;

" - &quot;
' - &apos;

-Bill Kearney
Nov 12 '05 #5
Bill Kearney wrote:

Because you can't. There 5 characters that MUST be encoded when used in
XML.

& - &amp;
< - &lt;
- &gt;


" - &quot;
' - &apos;


Actually only < and & must be escaped, the rest can be used in native
form too. http://www.w3.org/TR/REC-xml/#syntax

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #6

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

Similar topics

1
by: leegold2 | last post by:
The subject title is a sedgeway into my question that may slightly of topic but I've asked many sources and don't have an answer yet so I ask it here. I have a text fields of html marked up...
2
by: micha | last post by:
my php script gets delivered text that contains special chars (like german umlauts), and these chars may, may partially or may not be coverted into html entities already. i don't know beforhand. ...
13
by: Rick Brandt | last post by:
If you examine the complete XML below you will see an element "Notes" consisting of... <Notes>test replace test&amp;replace</Notes> As you can see I have properly (I think) escaped the ampersand...
5
by: kaeli | last post by:
Hey all, In trying to get my site to validate (html 4.01 transitional), I ran across an issue with this type of url in an href: http://www.server.com/somePage?param1=1&param2=2 etc Notably:...
4
by: MLH | last post by:
I have tried the following in the immediate window. It yields an error... ?"Hello"&vbCrLf&"there"&vbCrLf&"next"&vbCrLf&"line." 'Type declaration character does not match declared data type. ...
13
by: darrel | last post by:
I am creating a querystring to look like this: form_edit.aspx?collectionID=25&amp;confirmationMessage=New+form+entry+saved Note that I'm escaping the ampersand. However, I can't grab the...
12
by: Rich | last post by:
Strangely, on-page anchors will work on MSIE, but not on Netscape7.2 or Firefox1.5. All anchors are numbers e.g. <a href="#21">TOPIC</a> supposed to connect down to <a name="#21>beginning of...
7
by: Gene Kelley | last post by:
I'm having some trouble echoing string data that contains an ampersand in it. I am filling a WHERE clause in my SQL query with a string based upon a choice made in a select/option form element...
11
by: Steven D'Aprano | last post by:
I'm using urllib.urlretrieve() to download HTML pages, and I've hit a snag with URLs containing ampersands: http://www.example.com/parrot.php?x=1&y=2 Somewhere in the process, urls like the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.