Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
1522
preserveWhiteSpace
Is a member of:
XML DOM Document
Syntax
blnValue = objDOMDocument.preserveWhiteSpace
objDOMDocument.preserveWhiteSpace = blnValue
Remark
This property is a readable and writable property that returns
True/False. The default is False. White space is a space, tab, or carriage return (new
line) character in your XML file.
This property is useful when you need to preserve the layout
(white space) of the data in your XML document. For example, you
have as one of your elements a comment that consists of
sentences. You would need to preserve the two spaces after a full
stop, the carriage return between paragraphs. Well, if you did
not specify to preserve the white space for this element, you
would lose all this formatting.
In the XML specifications, all white space is meant to be
preserved; however, the default behavior of this property in the
DOMDocument is False, and as such, the XML and TEXT properties do
not preserve the white space.
The text and XML properties will preserve white space when the
user has set the preserveWhiteSpace property to True and/or when
the xml:space attribute on the XML element has the value
preserve. Depending on which you choose from the previous line;
the DOMDocument object handles the white space differently.
There are different types of white space:
Preserved: the content of the DOMDocument will be exactly as
it's found in the XML file
Trimmed: the leading and trailing spaced in your XML file are
removed
Half-preserved: the white space inside your text is preserved,
but the white space between tags is normalized
To find more information about how setting your white space
affects the output of your text in the DOMDocument, go to the
Microsoft website, which explains this quite well.
Example
The following XML example specifies that the white space needs
to be preserved:
<ADDRESS>xml:space="preserve">
911 Somewhere Circle,
Canberra,
Australia
</ADDRESS>
Now this data will keep its form when it is displayed.
This manuscript is an abridged version of a chapter from the
Manning
Publications book XMLProgramming with VB and ASP. This chapter
looks at the Microsoft DOM objects. NOTE: Most images have been
removed to increase speed and many of the code comments have also
been removed for presentation. Please purchase the book to enjoy
the full experience of all the chapters with images and code
comments!