XML: Frequently Asked Questions and Common Errors
The following article explains some common pitfalls which XML programmers need to be aware of. It presumes a fundamental grasp of basic XML syntax.
What do XML processors do with the white spaces used for indenting? Do they ignore them? The answer is a qualified yes.
Strictly speaking, the XML processor does not ignore white spaces. In the following example, it sees the content of name as a line break, three spaces, fname, another line break, three spaces, lname, and a line break.
<name> <fname>Jack</fname> <lname>Smith</lname> </name>
But in the following case, it sees the content of name as just fname and lname. No indenting.
It is easy to filter unwanted white spaces and most applications do it. For example, XSL (XML Stylesheet Language) ignores what it recognizes as indenting.
Likewise, some XML editors give you the option of indenting source code automatically. If they indent the code, they will ignore indenting in the document.
If whitespaces are important for your document, then you should use the xml:space attribute that was introduced earlier.