Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

Remove unwanted NewLine characters when using the XmlWriter class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB - 01 Jul 2007 15:16 GMT
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
mark.milley@binaryswitch.com - 02 Jul 2007 18:36 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.