   
preserveWhiteSpace
Is a member of:
|
XMLDOMDocument
|
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 XML
Programming 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!
|