Mr.Unknown
Mr.Unknown

Reputation: 180

What is the purpose of writing XML version?

I'm new to XML, I want to understand the basic.

 <?xml version="1.0" encoding="utf-8"?>

In that above code of xml, what is the purpose of

version="1.0"

I understand that this is XML version. but the question is

What is the purpose?

coz I searched, but I wasn't found an answer to clarify this to me. Can anyone help me, if this was a duplicate can you please comment the link. Thanks you Stackoverflow!

Upvotes: 0

Views: 598

Answers (1)

Josh Stevens
Josh Stevens

Reputation: 4221

Version

Specifies the version of the XML standard that the XML document conforms to. The version attribute must be included if the XML declaration is declared well-formedness constraint

The first line in an XML document is called the prolog:

<?xml version="1.0" encoding="UTF-16" standalone="yes"?>

Declaring the XML version is especially important now that XML 1.1 has been approved as a W3C Recommendation. XML 1.1 changes the definition of well-formedness in small but definite ways. One nice change is that XML 1.1 makes the XML declaration mandatory. The recommendation states: XML 1.1 documents MUST begin with an XML declaration which specifies the version of XML being used. The emphasis is mine. By definition, any XML document without a declaration is an XML 1.0 document. However, you should never leave the version unstated, especially since it is also very important to specify the encoding.

Upvotes: 1

Related Questions