The XML declaration is optional, and it refers to the 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, it must be in the document's first line.
  • To avoid errors, encoding should be used, or the XML file must be saved as UTF-8.
  • The default character encoding for XML documents is UTF-8.


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram