QML - Create Your Own Adventure

Introducing XML

XML means eXtensible Markup Language. It's a syntax to write many different markup languages for many different purposes. Just one of this purpose is a Choose-Your-Own-Adventure game system, and this language is QML, the Quest Markup Language. Another purpose could be writing a recipe, a description of a car or a webpage.

An XML file is basically a text-file that obeys certain rules.
Following these, the program reading your file doesn't have to reinvent the wheel by writing functionality that understands these rules. And the author of a document doesn't have to learn a new syntax for different languages based on XML.

The basics

XML consists mainly of elements and attributes.

Elements

An element is written like this:

<element>Hello World</element>

The actual content is just free text. It doesn't matter if you write "Hello World" or "Today is saturday". (You just should not use either "<" or ">".)
Surrounding this text is an opening tag to the left, reading <element>, and a closing tag to the right, reading </element>, and this time it's very important these are written like that. It must not be called "element", it could have many names, but if you would have used <a> as opening tag and </b> (or even </A>) as closing tag, the tool trying to understand your file will tell you you're going against the rules and it would reject your file.

Attributes

An attribute consists of an attribute-value pair, meaning the one won't go without the other.
It's written like this:

<element attribute="value">Hello World</element>

"attribute" (which could have any other name) is enclosed inside the opening tag of "element", meaning it's an attribute belonging to this element. The value, which must be in quotations, belongs to the attribute and defines it.
Here's a more meaningful example:

<text emphasis="strong">Hello World</text>

This means: Hello World has a strong emphasis. It could as result be displayed in big, bold letters.

Formatting

You can format the last sample in different ways while still obeying the XML rules:

<text
    emphasis="strong">
Hello World
</text>

Header

To make the XML file complete, include a declaration at the beginning of the file, so people or tools will know what it is:

<?xml version="1.0" ?>

(This looks a bit different than what was explained before.)

Wrapping it all up

To create a complete basic (what is called "well-formed") XML file, follow these steps:

<?xml version="1.0" ?>
<text>
Hello World
</text>

If you drag & drop the above file on the Internet Explorer 5 browser, you can see it will understand it!