473,657 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3569
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
3203
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
6239
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 print it out, the "&lang" gets converted into some strange character. i.e., just try: alert ("heyhey&lang=blahblah");
1
2040
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 gets changed to "&amp;#10" and doesn't render new lines in the Excel sheet. Can anyone help? Many thanks,
5
4334
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 framework took care of converting &amp; back to & But I'm wrong in that assumption. For every &amp; in the XML I receive
2
1740
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 character sequences. And as such, all ampersands should be converted to &amp; when employed as part of a URI. So I configured that manually, for my own parameters. However, I think what I'm seeing here with the validator, is that the validator does not...
11
1947
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 XMLDocument reader in .NET platform. How should people code & character as an ordinary data character? I don't mean any platform dependent solution just XML's point of view.
2
1773
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 exception. What do I need to do to display & nd other special chracters correctly in xml tags.
3
6655
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=" & HTTPUtility.URLEncode("500 Rt 6 & 209") and then to retrieve it: txtAddress1.text = Request.Querystring("AD1") However, in a different page of code, I loop through the QueryString.AllKeys collection like this:
0
1687
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 detecting and fixing these? At present I mostly don't notice ampersands until I get around to validating my pages. I don't validate nearly as often as I add invalid URIs. At the moment I have no idea of how to automate a fix. Google didn't...
0
8319
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
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
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
5638
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();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.