XML DOM » Document » preserveWhiteSpace

Compability: Internet Explorer


This property contains a boolean value of true if default processing preserves white space, or false otherwise. By default it is false.

When preserveWhiteSpace is true, all white space is preserved, regardless of any xml:space attibutes specified in the DTD; in fact it is equivalent to every element having an attribute of xml:space="preserve".

When preserveWhiteSpace is false, it is the values of any xml:space attributes alone that determine whether white space is preserved.

The xml property does not preserve white space exactly as in the original document; the object model replaces white space with a single new-line character in the returned representation. Similarly, the text property returns a representation of the original text without leading and trailing spaces, and replaces multiple, intervening white space characters with a single space character. Both of these properties preserve white space when preserveWhiteSpace is set to true and the element has an attribute of xml:space="preserve".