Home > Articles > Web Services > XML

XML: Frequently Asked Questions and Common Errors

📄 Contents

  1. XML: Frequently Asked Questions and Common Errors
  2. Why the End Tag?
  3. XML and Semantic
  4. Four Common Errors
  5. About this Article
  • Print
  • + Share This
The following article explains some common pitfalls which XML programmers need to be aware of. It presumes a fundamental grasp of basic XML syntax.

The following article explains some common pitfalls which XML programmers need to be aware of. It presumes a fundamental grasp of basic XML syntax.

Code Indenting

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.

<name><fname>Jack</fname><lname>Smith</lname></name>

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.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.