0

I know that we should include

<?xml version="1.0"?>
as the header of xml.
But if I don't include it in the xml doc like

<message>aaa</message>

What's the consequence?
I've try that my java SAX parser can't parse this xml without the header.

What's the consequence of this?
Will SAX parse without this header?
If it's legal, how to parse this type of XML?

Magic
  • 1,182
  • 2
  • 18
  • 28

1 Answers1

1

The XML declaration at the front of the file is optional. The consequence of omitting it is that the parser has to guess the character encoding of the file. In general it will guess UTF-8 unless there is other information available, such as an HTTP header.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164