The xml:space Attribute

The xml:space attribute can indicate the significance (or lack thereof) of white space within a particular element. It has two legal values, default and preserve. The value default means that the application may treat white space in the element in whatever fashion is customary for that application. For instance, it might trim off or compress excess white space. The value preserve means that white space is significant, even if it normally isn't, and the application should not adjust the white space in any way.

For example, the xml:space attribute of the text element below indicates that white space is significant and should be preserved.

 <text xml:space="preserve"> I try to make XML lean Without extra white space between ...

Get Effective XML: 50 Specific Ways to Improve Your XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.