Each XML file starts with a declaration statement that specifies the version and encoding used in the file and whether the file is standalone (schema used is internal). This is a sample XML declaration:
<?xml version="1.0" encoding="UTF-8"?>
The declaration is followed by a tree of XML elements, which are delimited by tags that have the following form:
- <tag>: Opening tag, defines the start of an element
- </tag>: Closing tag, defines the end of an element
- <tag/>: Self-closing tag, defines an element with no content
Usually, elements are nested so that there are tags inside other tags:
<outer>
<middle>
<inner1>content</inner1>
<inner2/>
</middle>
</outer>
Each element can have additional information in the form of attributes, which are space-separated key/value pairs found inside an opening or self-closing tag. The key and value are separated by an equals sign, and the value is delimited by double quotes. The following are examples of elements with attributes:
<tag attribute="value" another="something">content</tag>
<selfclosing a="1000" b="-1"/>