Sams Teach Yourself XML in 21 Days

Sams Teach Yourself XML in 21 Days

By Steven Holzner

Creating an XML Declaration

XML declarations tell XML processors what version of XML you're using, what character encoding the document is written in, and so on. According to W3C, all XML documents should start with an XML declaration, which should be the first line in an XML document. You can also have XML document fragments in some cases, which don't start with an XML declaration, although such fragments are losing support. Here's a sample XML declaration:

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

The XML declaration uses the <?xml?> element. In earlier drafts of XML, it was <?XML?>, but was made lowercase in the final recommendation—it's an error to use uppercase. There are three possible attributes you can use in the XML declaration:

Share ThisShare This

Informit Network