XML
Beginner
1 min read
The XML Prolog and Declaration
Example
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
XML Declaration breakdown:
version = "1.0" (required)
encoding = "UTF-8" (optional, defaults to UTF-8/UTF-16)
standalone = "yes" (optional: "yes" means no external DTD needed)
-->
<!-- Processing instruction: attach an XSL stylesheet -->
<?xml-stylesheet type="text/xsl" href="books.xsl"?>
<!-- DOCTYPE declaration referencing an external DTD -->
<!DOCTYPE bookstore SYSTEM "bookstore.dtd">
<!-- Root element — only one allowed per document -->
<bookstore>
<!-- Character data (text node) -->
<title>XML Fundamentals</title>
<!-- CDATA section: content not parsed by the XML parser -->
<description><![CDATA[
This book covers <XML> & related technologies.
Special characters like < > & need no escaping here.
]]></description>
<!-- Entity references for reserved characters -->
<note>Use < for less-than and & for ampersand.</note>
</bookstore>