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

ASCII control characters in CDATA section

Hi,

I need to preserve some ASCII control characters (CR and LF) within an
XML file so I have included the data in a CDATA section. However,
when parsing it using expat, I lose the CR characters.

My question is: Should I be using a different character set (not
UTF-8) or is this a bug in expat?

TIA, Mark

Jul 20 '05 #1
2 6455


no*****@home.com wrote:
I need to preserve some ASCII control characters (CR and LF) within an
XML file so I have included the data in a CDATA section. However,
when parsing it using expat, I lose the CR characters.

My question is: Should I be using a different character set (not
UTF-8) or is this a bug in expat?


I don't think so, with XML all line endings are normalized
http://www.w3.org/TR/REC-xml#sec-line-ends
so even a CDATA section doesn't help to preserve a carriage return
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
In article <hs********************************@4ax.com>,
<no*****@home.com> wrote:
I need to preserve some ASCII control characters (CR and LF) within an
XML file so I have included the data in a CDATA section. However,
when parsing it using expat, I lose the CR characters.


To preserve CRs, you need to use character references (&#x0D;), because
CR and CR-LF are normalized to LF when an XML document is read.

You can't use character references in a CDATA section, so it's
probably better to forget about CDATA and just escape any characters
that need it. The main use for CDATA is preserving human readability
of text that includes < and & characters, such as XML examples inside
an XML document. It doesn't really work for arbitrary data.

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #3

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

Similar topics

6
by: Dario Di Bella | last post by:
Hi all, I hope someone can help me on this. I need to parse the following XML: .... <area name="promotore"> <item id="004" code="003" description="attivita promotore"> <!]> </item> </area>...
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
6
by: Cade Perkins | last post by:
How can the CDATA ending delimiter "]]>" be represented within a CDATA section itself? Consider an XML document that is intended to contain an embedded, uninterpreted XML example. Generally,...
2
by: eggie5 | last post by:
I have a custom object named #cdata-section, however I am unable to access this object and get a run time "Illegal Character" javascript error. my object looks like this: ...
18
by: sim.sim | last post by:
Hi all. i'm faced to trouble using minidom: #i have a string (xml) within CDATA section, and the section includes "\r\n": iInStr = '<?xml version="1.0"?>\n<Data><!]></Data>\n' #After i...
3
by: raga | last post by:
Hi Could you please let me know When i specify an attribute of an XML Tag as CDATA in DTD , can i use & straight away within the value of that attribute (instead of using & AMP ;) . If we...
6
by: Andy Leese | last post by:
Beginner Question: ASCII Symbols I am using Borland C++ and programming under DOS. I wish to display the symbols of the early ASCII character set... For example: cout << char(7); ...
1
by: s123 | last post by:
Hi, while invoking a web service, if in xml request message i wrap the extended ASCII characters with CDATA it is not returning the desired result, while this is not the case if i do not wrap...
9
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string....
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
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
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
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...
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...
0
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...

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.