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

How to prevent line breaks in XML file?

les
I am creating XML from SQL2000 using a vb.net page, then posting it to
a remote server as a string.

The remote server requires that the xml contain no line breaks, but
there are some ntext fields in the database that contain long text
with line breaks.

How do I get rid of the line breaks? Can I do this with the
XmlTextWriter, or do I need to handle each affected field seperately
before handing it to the XmlTextWriter?

Thanks
Leslie
Nov 12 '05 #1
3 2216
les wrote:
How do I get rid of the line breaks? Can I do this with the
XmlTextWriter, or do I need to handle each affected field seperately
before handing it to the XmlTextWriter?


Both ways are possible. While it's probably simpler to run
String.Replace() on each string you are writing out, you can also create
custom XmlTextWriter (deriving from XmlTextWriter) and override
WriteString method to encapsulate replacement logic.

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2
les
Thanks Oleg,

I'm used to doing this the other way around eg:
replace(litDetails.Text,chr(10),"&nbsp;<br>")

but now I have:
textWriter.WriteString(rdr3.Item("details"))

How would I do the necessary replacement here?
Thanks
Leslie


On Mon, 26 Apr 2004 10:30:09 +0200, "Oleg Tkachenko [MVP]"
<oleg@NO!SPAM!PLEASEtkachenko.com> wrote:
les wrote:
How do I get rid of the line breaks? Can I do this with the
XmlTextWriter, or do I need to handle each affected field seperately
before handing it to the XmlTextWriter?


Both ways are possible. While it's probably simpler to run
String.Replace() on each string you are writing out, you can also create
custom XmlTextWriter (deriving from XmlTextWriter) and override
WriteString method to encapsulate replacement logic.


Nov 12 '05 #3
les wrote:
I'm used to doing this the other way around eg:
replace(litDetails.Text,chr(10),"&nbsp;<br>")

but now I have:
textWriter.WriteString(rdr3.Item("details"))

How would I do the necessary replacement here?


Something like

string[] lines = text.Split('\n');
foreach (string line in lines)
{
textWriter.WriteString(line);
textWriter.WriteStartElement("br");
textWriter.WriteEndElement();
}

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

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

Similar topics

0
by: DJ Craig | last post by:
I have a cell phone with full internet access. I have an HTML page that I wrote specifically for use on my cell phone. It uses PHP's fopen() to open files on my server and then displays the...
6
by: Jonathan | last post by:
I want to save textarea contents to a mysql database with the paragraph breaks intact without having to type paragraph or break tags in HTML. How can I do that. So far, although it occurs naturally...
1
by: KathyB | last post by:
Hi, I'm using xml transformed to html via xsl. The problem is my HTML source text auto wraps/breaks lines. This only matters when the line involves a parameter I'm passing to a script...which then...
4
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary...
9
by: jsummit | last post by:
I'm trying to parse a rather large string from a .txt file that breaks into 2 lines ( the string is a fixed-length string reaching 6694 characters) into a dataset using VB.net. The issues that I am...
5
by: joelbyrd | last post by:
Didn't know exactly where to post this, but: How do I get line breaks in a textarea? I'm pulling text from a database, and this text definately has line breaks in it, because I replaced all the...
8
by: Juan Puebla | last post by:
Hi, I have an sql database with some text (nvarchar) fields. The problem is that if I get those fields with a datareader (dr.getstring(0)) an then I save text in a txt file I loose all the line...
2
by: caspardh | last post by:
i was trying to code a morse code decipherer which workd fine except that the .txt file that i was converting had linebreaks built in, i cant get python to ignore the line breaks and i cant find any...
6
by: Stick | last post by:
Hi, I am trying to start my email app (in this case Eudora) with a programatically generated email. However, Eudora does not seem to recognize any of the ways I have tried to create line...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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...

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.