Special Content
Character Entities
&
&
Ampersand
<
<
Less-than sign
>
>
Greater-than sign
"
"
Double quote
'
'
Single quote / apostrophe
Usage Example
<note>
<message>Use <tag> to define elements & attributes.</message>
</note>
Processing Instructions
What are Processing Instructions?
Processing Instructions (PIs) provide directions to applications processing the XML document. They are not part of the document’s data but offer instructions or hints to XML parsers or applications.
Syntax
<?target instructions?>
target
specifies the application to which the instruction is directed.instructions
contain the information or commands.
Example
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<note>
<to>Alice</to>
<from>Bob</from>
</note>
This example links an XSL stylesheet to the XML document.
Encoding
Specifying Encoding
Encoding is declared in the XML declaration at the top of the document:
<?xml version="1.0" encoding="UTF-8"?>
The most common encoding is UTF-8, which supports all Unicode characters.
Other encodings (like ISO-8859-1) can also be specified but UTF-8 is recommended for compatibility.
Important Notes
The encoding declaration must match the actual byte encoding of the file.
If encoding is omitted, parsers assume UTF-8 or UTF-16 by default.
Incorrect encoding declaration can cause parsing errors or misinterpreted characters.
Last updated