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 / C# / January 2008

Tip: Looking for answers? Try searching our database.

XmlDocument - while saving end tage moves to next line

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Venu - 11 Jan 2008 17:26 GMT
I use XmlDocument to load and save the XML document...

While i save the document end tag of elements with blank value is moved to
next line..

i.e.
<root>
  <element1>some text</element1>
  <element2>123566</element2>
  <element3></element3>
  <element4></element4>
</root>

when above document is loaded and saved back, it looks like below
<root>
  <element1>some text</element1>
  <element2>123566</element2>
  <element3>
  </element3>
  <element4>
  </element4>
</root>
(End tags of element3 and elemtn4 are moved to next line)

This causes error in my schema as element3 and element4 has invalid
character(in schema we have defined, it must have valid value, blank space is
invalid)

XML file is generated via code so - i can’t change  <element4></element4> to
 <element4/> to avoid above problem...

Please can help me how to handle this..

Cheers
Venu
Nicholas Paldino [.NET/C# MVP] - 11 Jan 2008 17:58 GMT
Venu,

   A few things I can think of to check.  First, is the schema attached to
the XmlDocument and are you calling Validate on the document to make sure
that the document conforms to your schema before you write it?

   Also, what is the setting on the PreserveWhitespace property on the
XmlDocument instance?

   Finally, are you creating your own XmlWriter/XmlTextWriter?  There are
settings on this that you can use to fine-tune the whitespace
preservation/handling.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I use XmlDocument to load and save the XML document...
>
[quoted text clipped - 33 lines]
> Cheers
> Venu
Venu - 11 Jan 2008 18:36 GMT
Nicholas,

Setting PreserveWhitespace = true works fine for me... It is now formatted
well and works fine with the schema.

Thanks a lot fo your help...

Cheers
Venu

> Venu,
>
[quoted text clipped - 46 lines]
> > Cheers
> > Venu

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.