How can I send XML files to the Customer Care team?

Add XML declaration in the first line

When you create an XML document quickly, it can be very tempting to create the basic structure and eschew the normal XML document requirements of specifying the XML declaration and the encoding type of the data that the XML document contains.

Consider the XML document in Listing 1.

Listing 1. XML document minus the XML declaration and data encoding type


  <phrase lang="en">Hello</phrase>
  <phrase lang="it">Buongiorno</phrase>
  <phrase lang="fr">Salut!</phrase>


As a human, you can look at that document and identify it as XML, but it is more difficult for a computer to achieve the same determination. You can make the process more explicit and identifiable by adding the XML declaration to the top of the file. This is a single line that specifies that the document is XML, and also describes a version number and the character encoding used in the XML data. For example:


<?xml version="1.0" encoding="us-ascii"?>


The content of the encoding specification should be accurate, too. The encoding is used by XML parsers to ensure that the individual character is loaded correctly from the XML document.