XML Declaration

XML declaration is optional, and it refers to version and encoding of the XML document. This lesson describes the XML declaration with examples.

XML Declaration

Syntax:
<?xml version="1.0" encoding="ISO-8859-15"?>
XML Example:
<?xml version="1.0" encoding="ISO-8859-15"?>
<address>
  <name>Alex</name>
  <company>w3schools</company>
  <phone>(091) 123-4567</phone>
</address>
  • Declaration of XML is also called the XML prolog.
  • prolog of XML is case sensitive and must be written in lower-case.
  • XML prolog is optional, but if required then it must be in the first line of the document.
  • To avoid errors, encoding should be used, or XML file must be saved as UTF-8.
  • The default character encoding for XML documents is UTF-8.

Courses
Subscribe Updates via Email

Join 49,000+ W3schools lovers and get all the latest tutorials, programs, algorithms in your inbox.