Saturday, 14 November 2015

XML Declaration

XML Declaration

The XML declaration appears as the first line in an XML document.

The XML declaration is not required, however, if used it must be the first line in the document and no other content or white space can precedeit.

version number

The version number is mandatory. Although number might change for future versions of XML, 1.0 is the current version.


<?xml version="1.0"?>


encoding declaration

The encoding declaration is optional.

If it is used, the encoding declaration must appear immediately after the version information in the XML declaration, and must contain a value representing an existing character encoding.


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


The encoding declaration identifies which encoding is used to represent the characters in the document. Although XML parsers can determine automatically if a document uses the UTF-8 or UTF-16 Unicode encoding, this declaration should be used in documents that support other encodings.

Example:ISO-8859-1 (Latin 1).


<?xml version="1.0" encoding="ISO-8859-1"?>

Note:

XML is case sensitive however Case in the value specified is not considered by the encoding declaration. "ISO-8859-1" is the equivalent of "iso-8859-1".

standalone declaration

The standalone declaration is optional. If used, the standalone declaration must appear last in the XML declaration.


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


The standalone declaration indicates whether a document relies on information from an external source, such as external document type definition (DTD), for its content.
If the standalone declaration has a value of "yes", the parser will report an error if the document references an external DTD or external entities.

Leaving out the standalone declaration produces the same result as including a standalone declaration of "no". The XML parser will accept external resources, if there are any, without reporting an error.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...