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 / .NET Framework / XML / February 2007

Tip: Looking for answers? Try searching our database.

retaining leading whitespace in text of an xml node

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Richter - 19 Feb 2007 16:23 GMT
when I run the following code the leading spaces of the "data" node
are removed. How do I retain whitespace?

   private void CreateBasicXmlDocument()
   {
     XmlWriterSettings writeSettings = new XmlWriterSettings();
     writeSettings.Indent = true;

     XmlWriter writer = XmlWriter.Create( filePath, writeSettings );

     writer.WriteStartElement("data");
     writer.WriteWhitespace(" ");
     writer.WriteValue("     data with leading space");
     writer.WriteEndElement();
     writer.Close();
   }
Bjoern Hoehrmann - 21 Feb 2007 06:11 GMT
* Steve Richter wrote in microsoft.public.dotnet.xml:
>when I run the following code the leading spaces of the "data" node
>are removed. How do I retain whitespace?
[quoted text clipped - 12 lines]
>      writer.Close();
>    }

How do you expect the writer to know when your white space is and is not
significant to you? It needs to know because you are asking it to indent
your content, which necessarily implies changes in the amount of white
space. If you turn automatic formatting off, your white space should be
preserved.
Signature

Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


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.