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

Remove unwanted NewLine characters when using the XmlWriter class

JB
Hi All,

I'm writing XML in VB.NET 2005 using the System.Xml.XmlWriter class.
It's all working fine but I'd like to remove a few NewLine characters.

For instance if I use the following code:
Writer.WriteStartElement("Name")
oObject.WriteXml(Writer) 'This object writes it's ow
Writer.WriteEndElement("Name")

The XML produced is (on 3 lines):
<Name>
<CField FieldType="String">Query 2</CField>
</Name>

I would like to get the same XML but on 1 line:
<Name><CField FieldType="String">Some Name</CField></Name>

I tried to use the WriteRaw method of the XmlWriter class, it works
but it requires handling the alignment manually which can become a bit
messy.

Any ideas on how to do that?

Thanks
JB

Jul 1 '07 #1
1 4733
Hi JB -

Write the output to a string, then run a quick replace on it. ie:

strVal = strVal.Replace(System.Environment.newline, "")

Good Luck,

-Mark

Jul 2 '07 #2

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

Similar topics

5
by: Brian Reed | last post by:
I have a class that I want to serialize to an XML string. I want the XML to serialize to utf-8 encoding. When I serialize to an XML file, the data looks great. When I try to serialize to a String...
1
by: Joe | last post by:
I want to save some URLs into a XML formatted document. > > I find out that its having some problems due to some of the characters > used > in the URL. > > Is there a quick way to get around...
5
by: Adam Right | last post by:
Hi, Is there a way to construct the mail body including newline characters by using .net framework mailing functions when sending an email? I cannot insert newline character into the body of the...
2
by: John A Grandy | last post by:
I know that System.Security.SecurityElement.Escape() will replace invalid xml chars with valid equivalent ... But is there another method to accomplish same that is "closer to home" ?
1
by: romiko2000 | last post by:
Hi Folks, I got a weird problem, I create an XMLWriter to post a document via the webrequest stream and after running a network trace, I notice the data is prefixed with 3 invalid characters! ...
3
by: Danny Yeadon | last post by:
Hi I need to remove unwanted characters from phone numbers from my phone bill to analyse the data. Some examples are 02 48222222 i need to remove the space +61266667656 ...
0
by: Janusz Nykiel | last post by:
I've stumbled upon unexpected behavior of the .NET 2.0 System.Xml.XmlWriter class when using it to write data to a binary stream (System.IO.Stream). If the amount of data is less than a certain...
7
by: JB | last post by:
Hi everyone, I'm having problems with Tab characters in an XML file. I want to store a Tab character as part of an element value e.g. <Separator>TAB</Separator> I'm using XmlWriter to write my...
3
by: ofilha | last post by:
I am trying to export the resultset of a query to a character delimited file. I am using the wizard for this. However, one of the fields is 512 characters long and it accepts from form address. It...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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?
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
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,...

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.