Importance of indenting XML file

No, the XML spec define whitespace like this:

In editing XML documents, it is often convenient to use "white space" (spaces, tabs, and blank lines) to set apart the markup for greater readability. Such white space is typically not intended for inclusion in the delivered version of the document. On the other hand, "significant" white space that should be preserved in the delivered version is common, for example in poetry and source code.

So in terms of parsing the document, no. You can use as much or as little as you want or need and it will parse correctly. This may or may not change the meaning of the XML document, however.

Indenting XML tags is never required for parsing. However, the point of XML is to be human as well as machine readable, so indentation is generally worth having, as it makes it far easier for human readers to work with and take in the structure at a glance.


Short, short, short answer: Nope.

Longer answer: It depends on your application whether or not whitespace is significant. If you indent your XML file you add whitespace which sometimes has meaning to the application processing the data contained.

But for parsing the XML file? Whitespace does not influence the parse-ability, no. See the whitespace handling section of the XML specification.

Tags:

Xml