473,399 Members | 3,106 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,399 software developers and data experts.

Ignoring ampersand(&) as a special character in xml

Let's say I have the following xml tag:

<para role="source">a & b</para>

Currently, an xml parser will treat & as a special character. Does
anyone know the special characters to use around the ampersand so that
the xml parser can treat "a & b" as a whole value?

Thanks
Thierry

Sep 6 '05 #1
2 3546
Thierry Lam wrote:
Let's say I have the following xml tag:

<para role="source">a & b</para>

Currently, an xml parser will treat & as a special character. Does
anyone know the special characters to use around the ampersand so that
the xml parser can treat "a & b" as a whole value?

Thanks
Thierry


Simple use the XML Entity for & which is &amp;

<para role="source">a &amp; b</para>

You could use CDATA sections too but they seem to have the effect on
people ignoring that the containing strings are actually literary what
they seem (in this case "a & b") and not what they really are ("a &amp;
b")...

chris

Sep 6 '05 #2
Chris wrote:
Thierry Lam wrote:
Let's say I have the following xml tag:

<para role="source">a & b</para>

Currently, an xml parser will treat & as a special character. Does
anyone know the special characters to use around the ampersand so that
the xml parser can treat "a & b" as a whole value?

Thanks
Thierry

Simple use the XML Entity for & which is &amp;

<para role="source">a &amp; b</para>

You could use CDATA sections too but they seem to have the effect on
people ignoring that the containing strings are actually literary what
they seem (in this case "a & b") and not what they really are ("a &amp;
b")...


should read before posting..., of course the other way round:
some people seem to ignore the visible "a & b" is not the actual "a
&amp; b" in CDATA sections...

chris

Sep 6 '05 #3

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

Similar topics

2
by: petermichaux | last post by:
Hi, I'm trying the following code (ultimately I want a node with a URI like index.php?foo=1&bar) <?php $foo = new DomElement('foo','foo&bar'); ?>
2
by: Genzo | last post by:
Hi all, was wondering if anyone might have knowledge on this. am testing with Opera 7.11. essentially whenever i try to use the substring "&lang=" in any string value in javascript, and try to...
1
by: st | last post by:
Hi, I'm using xmlDocument.Save(xmlTextWriter) to create an Excel-readable file. All works well, except where I've replaced the carriage return chars in the .innertext to XML-compliant " "; It...
5
by: David Bartosik [MSFT MVP] | last post by:
I'm parsing an XML file with XMLDocument, each node I write to SQL server. Sometimes values in the XML have to contain an ampersand, so they are in the XML as &amp; obviously. I assumed the .net...
2
by: Jim Carlock | last post by:
http:/ / aquaticcreationsnc . com/lib/php/test.php Remove the spaces to visit the link above... The w3 validator identifies the ampersand character as the leading character for special...
11
by: BenI | last post by:
Hello, I have a XML file using Iso 8859-1 encoding. Every time when I try to put & character as Tag's value like <tag>This is & character</tag> Exception is shown in my application. I use...
2
by: NAT | last post by:
I have a xml open and close tag <abc</abc>. I assign a string variable to this tag. <abc& NAT & </abc. The value of the variable NAT = Cal&FLo. But due to the presence of the ampersand. There is an...
3
by: Elroyskimms | last post by:
I have to encode an address which contains an ampersand (&) into a URL with various querystring parameters. The following code works fine: URLString = "www.myserver.com?AD1=" &...
0
by: Eric Lindsay | last post by:
I encounter an annoying number of ampersands in URIs I copy and paste into blog style diary entries, written in HTML with a text editor. Does anyone happen to know of reasonably reliable method of...
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: 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
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...
0
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,...

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.