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

PreserveWhiteSpace not preserving all whitespace

I'm using C# and .NET 2

I am creating an XmlDocument object and setting PreserveWhiteSpace to True,
I use loadXMl to load XML from a file but when I look at the XML of the document object some of the whitespace has been stripped.

I need to EXACTLY maintain the original formatting of the file.

I want to use an XMLDocument as I need to query it using XPath and amend and add nodes.

Here is the original XML ...

Expand|Select|Wrap|Line Numbers
  1. <El1>
  2.   <El2>
  3.     <MCG 
  4.       class="UnionCodeGroup" 
  5.       version="1" 
  6.       PermissionSet="Full">
  7.       <MemberShip 
  8.         class="MembershipClass" 
  9.         version="1" 
  10.         Url="http://www.thescripts.com/"
  11.       />
  12.     </MCG>
  13.   <El2>
  14. </El1>
After I load it into the document it looks like this ...
Expand|Select|Wrap|Line Numbers
  1. <El1>
  2.   <El2>
  3.     <MCG class="UnionCodeGroup" version="1" PermissionSet="Full">
  4.       <MemberShip class="MembershipClass" version="1" Url="http://www.thescripts.com/"/>
  5.     </MCG>
  6.   <El2>
  7. </El1>

I know that it shouldn't make any difference as they are functionally the same but the 3rd party application that uses this file does requirte the formatting to be maintained (the attributes must be on different lines)

Any help on how I can preserve the original whitespace completely would be very welcome.

Thanks
May 3 '07 #1
2 2335
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN...

I'm afraid that the only solution to preserve exactly the text format is to open/edit the XML as simple text file.
The XMLDocument object seems to ignore spaces/new lines inside of < > tags.
May 3 '07 #2
Thanks for the reply. I suspected that was the case. I was trying to avoid treating it as a simple text file but feared it was the only solution.

Fergus
May 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: R | last post by:
Hello everybody. I've got problem with preserving whitespaces: $doc->preserveWhiteSpace = false; works fine up to the point when I try to load external XML file. // up to this point...
1
by: Oleg Dulin | last post by:
Colleagues: Does anyone know if there are less-lossy XML parsers and serializers that can capture and reproduce the structure of the input XML file including tabulation,whitespace, etc. ? We...
1
by: Riko Eksteen | last post by:
Hi I'm reading an xml file into an XmlDocument, adding some nodes, and writing it back out. I would like the nodes I add to assume the same level of indeting as the rest of the document. (I load...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
0
by: ryang | last post by:
Hi, PreserveWhitesapce property doesn't seem to work for me in various ways. Here are samples that I tried. First the XmlDocument is loaded with PreserveWhitespace = true. XmlDocument xmlDoc...
0
by: Shaun Dore | last post by:
Hi, What is the Xml DOM PreserveWhitespace property supposed to do? I thought that setting it to false would remove the superfluous white spaces? For instance, in the following code I would...
3
by: zjw2112 | last post by:
Hello. I have some javascript code that dynamically creates a textarea and sets the wrap value to hard, which I thought would preserve CR/LF in the textarea: var otherTextArea =...
3
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I just noticed something that seems counter-intuitive to me. By default an XmlDocument is set with PreserveWhitespace=false. This means that XmlDocument.Load() or .LoadXml() will...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.