-
Notifications
You must be signed in to change notification settings - Fork 85
Languages: Dutch (Nederlands)
A large part of this library is about controlling the behavior of a GUI by using XML files. If you're unfamiliar with the XML format, you can find a small overview of the workings of an XML file as well as the terminology used to describe several parts of XML files. Note that this is not a complete reference for the XML format. This page only explains the XML format to an extent needed for the workings of this framework.
XML files are stored in a .xml file.
An XML file relies on the fundamental parent/child system. A parent/child system works as follows. Every element (we'll explain elements more in-depth later) has exactly one parent (an exception to this is the top-element, which has no parents) and zero to infinite children.
Let's take a look at a sample XML file and analyze its components.
<pets>
<cats>
<cat age="13">Bella</cat>
<cat age="16">Tigger</cat>
</cats>
<dogs>
<dog age="16" alive="false">Bailey</dog>
<dog age="24">Max</dog>
<dog age="11">Lucy</dog>
</dogs>
</pets>
Here we have an XML file of our pets, so let's so how it works.
All around the file you see these <
>
signs with text in them. These are called tags. Some of these tags have a /
in front of their text, which indicates that these are closing tags.
<pets> An opening tag
</pets> A closing tag
A pair of tags with the same name and indentation together with the text or child elements is called an element.
<pets>
...
</pets> This is an element
We can see that in the case of pets
, nothing is above it, i.e. it has no parent. In this case pets
is the top-level element. Every file can only have one top-level element.
Each element can have children.
<pets>
<cats>
...
</cats>
<dogs>
...
</dogs>
</pets>
We can see that both cats
and dogs
are children of pets
. Or, pets
is the parent of both cats
and dogs
.
Inside cats
we can see multiple other elements, named cat
.
<cat age="13">Bella</cat>
In the opening tag we see something special, namely age="13"
. This is an attribute. An attribute is an additional property for the element. An attribute is made up of two parts, an attribute key and an attribute value. The attribute key is the value before the =
sign, in this case age
. The attribute value is the value after the =
sign, in this case 13
(we omit the "
quote signs). Note that an attribute value has to be a string (which is why it is surrounded with "
signs).
We can have multiple attributes inside one element as seen with one of the dogs:
<dog age="16" alive="false">Bailey</dog>
Poor Bailey has passed away, so it's alive
attribute has been set to false.
Last of all we can see that, unlike the pets
, cats
and dogs
elements, the cat
and dog
elements don't have any elements inside of them.
<dog age="11">Lucy</dog>
These elements simply have text inside of them, which we just call text or text content.