473,804 Members | 4,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Problem writing \r\n

Hello All,
I'm having trouble writing some special characters to an XML file.

I need to output a XMLSS formatted file to be read by Excel.

In some cells there will be some text that contains CR-LF pairs such
as
"this is a long entry\r\nThis is the secondline".

I'm building an XML document to represent my Excel data. This is
working fine.
Then I'm calling xmlDoc.Save(xml TextWriter)
to create the output.

The problem is that the \r\n are not denoted in any special manner in
the XML file. So Excel does not recogize the line breaks in the cell.

After some toying with the data, I find that this output would work
best:
<Cell>
<Data ss:Type="String ">
This is a long entry This is the secondline
</Data>
</Cell>

However I don't seem to be able to generate the ' ' in the XML
output.

What Value/InnerText do I set on my Text node so that the ' ' gets
send to the output XML file?

Any help is appreciated.

-tomas

Nov 23 '05 #1
1 3906
For the Benefit of the search engines....
I modified the function that creates the <Cell></Cell> tags to perform
a couple of additional tests to determine whether a "\r\n" exists in
the data object being written out.
If the (string) object contains a "\r\n", then I create a CDATA node,
otherwise I create a Text node to output the data.

The CDATA node preserves the newlines and is input as a literal by
Excel, so the data is represented as expected.

-tomas

On Tue, 22 Nov 2005 01:02:19 GMT, Tomas Vera
<ta**********@s bcglobalREMOVE. net> wrote:
Hello All,
I'm having trouble writing some special characters to an XML file.

I need to output a XMLSS formatted file to be read by Excel.

In some cells there will be some text that contains CR-LF pairs such
as
"this is a long entry\r\nThis is the secondline".

I'm building an XML document to represent my Excel data. This is
working fine.
Then I'm calling xmlDoc.Save(xml TextWriter)
to create the output.

The problem is that the \r\n are not denoted in any special manner in
the XML file. So Excel does not recogize the line breaks in the cell.

After some toying with the data, I find that this output would work
best:
<Cell>
<Data ss:Type="String ">
This is a long entry This is the secondline
</Data>
</Cell>

However I don't seem to be able to generate the ' ' in the XML
output.

What Value/InnerText do I set on my Text node so that the ' ' gets
send to the output XML file?

Any help is appreciated.

-tomas


Nov 23 '05 #2

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

Similar topics

48
8518
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential problem. The program may crash unexpectedly while writing to the file. If so, my program should detect this during startup, and then (during startup) probably delete the data added to the file and redo the writing operation.
6
23609
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
5
45738
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long *air_address;
102
7153
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality of its documentation, it is a impeccability. it has or possesses properties of:
16
7191
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain unchanged). How can I do that in Python? Claudio Grondi
6
5278
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
3
2699
by: Barry Flynn | last post by:
Hi I am working with a VB 2005 program which has been converted from VB6. It writes data out to a flat file, with code like the following line WriteLine(riFileNo, "Hist", lsAssetID, lsRecordType, lsXNbr, lsFiscYr, "Beg", CStr(H.BegBalAccDepn), CStr(H.BegBalCost), CStr(H.BegBalCostReval), CStr(H.BegBalDepCost), CStr(H.BegBalDepnReval)) The program is running from within a Virtual PC
89
3877
by: Skybuck Flying | last post by:
Hello, This morning I had an idea how to write Scalable Software in general. Unfortunately with Delphi 2007 it can't be done because it does not support operating overloading for classes, or record inheritance (records do have operator overloading) The idea is to write a generic integer class with derived integer classess for 8 bit, 16 bit, 32 bit, 64 bit and 64 bit emulated.
1
1318
by: san1014 | last post by:
Hi, I have a table SQL> select * fom temp; FID TID RN ---------- ---------- ---------- 1 2 1 1 3 2 1 4 3 2 1 1 2 5 2
5
5606
by: sonalshastry | last post by:
Hi i want to write a cursor where in branch name should be passed into the cursor one by one, I have a bill table with following detail Client, bill_date,bill_amount, branch ... I need to fetch data for top 5 client from every branch below query gives me the data across for branch A
0
9706
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...
1
10319
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,...
0
10076
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
9144
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
7616
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
6851
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
5520
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...
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
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.