XML Whitespace

XML > Structure > XML Whitespace

There are 3 types of whitespace within an XML document, XML Syntax, Significant and Insignificant.

<?xml version="1.0" ?>
<Address type=" billing">
<House >1630</House>
<Street> Revello Drive</Street>
Follow Route 1
Left After crossing
First house with green door</Directions>

   XML Syntactical whitespace

This is whitespace required by the XML Spec in order to delimitate XML constructs. The XML parser digests this all internally, it is not passed on to the application consuming then XML.

   Insignificant Whitespace

This is whitespace that is not considered part of an element, if 2 element tags are separated by just whitespace its considered insignificant.

An XML parser processes this information, and may pass it to the underlying application marked as insignificant whitespace.

Insignificant whitespace is typically added to an XML file in order to format it, provide the indenting etc. and in principal it has not impact on the meaning of the document.

   Significant Whitespace

Significant whitespace is whitespace contained within XML element, attribute, or processing instruction data. The XML parser will passed this on to the consuming application as data.

Whitespace Normalization

When an XML Schema is being used, the schema can impose its own whitespace rules on the data contained in elements and attributes. This can cause leading/trailing whitespace to be removed and runs of whitespace converted into a single space, see DTD Whitespace Rules and XSD Whitespace Rules.

EBNF Syntax

The characters that XML considered to be whitespace are described by the W3C as using EBNF as follows (space, tab, carriage return, line feed).

[3]   S                 ::= (#x20 | #x9 | #xD | #xA)+

See Also

Try Liquid XML Free and see how we can help you today Free Trial