Click to return to the XML (Extensible Markup Language) home page    
XMLDOMDocument parseError...     XMLDOMDocument readyState...     XMLDOMDocument Object    
Web Workshop  |  XML (Extensible Markup Language)

preserveWhiteSpace Property


Contains true if default processing preserves white space, or false otherwise.

Syntax

boolVal = objXMLDOMDocument.preserveWhiteSpace;
objXMLDOMDocument.preserveWhiteSpace = boolVal;

Remarks

Boolean. The property is read/write. This property is initialized to false.

The preserveWhiteSpace property specifies the default white space handling. When preserveWhiteSpace is true, all white space is preserved, regardless of any xml:space attributes specified in the DTD. It is the equivalent of having an xml:space= "preserve" attribute on every element.

When preserveWhiteSpace is false, the values of any xml:space attributes determine where white space is preserved.

The xml property does not preserve white space exactly as it appeared in the original document. Instead, the object model replaces white space present in the original document with a single newline character in the representation returned by the xml property. Similarly, the text property contains a representation without the leading and trailing spaces and replaces multiple intervening white space characters between words with a single space character.

The text and xml properties preserve white space when  preserveWhiteSpace property is set to true and when xml:space on the XML element has the value preserve.

This member is an extension of the W3C DOM.

Example

The following example first loads and displays a file with the preserveWhiteSpace property set to True, then reloads and displays the file with preserveWhiteSpace property set to False:

Dim xmlDoc  

Set xmlDoc = CreateObject("microsoft.xmldom") 
xmlDoc.async = False
xmlDoc.load("c:\books.xml")
xmlDoc.preserveWhiteSpace = True
MsgBox xmldoc.xml

xmlDoc.async = False
xmlDoc.load("c:\books.xml")
xmlDoc.preserveWhiteSpace = False
MsgBox xmldoc.xml

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
XMLDOMDocument

See Also

White space handling


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.