Well I wrote my reply less than an hour ago, but sure
XML is just a widely used way to write a textfile to contain data. It consists of elements inside elements with some basic information.
This is often used for things like saving settings for a game, or in our case saving which compounds exist and how the gui is set up.
The most important thing in an XML file is the tags/elements. An element is simply started as "<my_element_name>" then you put something inside, usually just more elements or some text and then you end the element with: "</my_element_name>" (note the slash). So XML is just these elements with more elements or text inside them.
Say we want to make a simple XML file containing a student with his name and age, we could write some basic XML like this (note that there are many different correct ways to write XML):
- Code:
-
<student>
<name>
James
</name>
<age>
16
</age>
</student>
So we start with a student element and we put a name element and an age element inside it, and those then have text inside them.
Say we want to save 3 students in a class with their name and their age, we could write an XML file like this:
- Code:
-
<class>
<student>
<name>
James
</name>
<age>
16
</age>
</student>
<student>
<name>
Henry
</name>
<age>
17
</age>
</student>
<student>
<name>
Joe
</name>
<age>
16
</age>
</student>
</class>
So we made a class element, and put 3 student elements in it. Each student element then has a name element and an age element!
And thats basic XML!
Now it can be annoying to have to write every piece of information about a student as a seperate element, the way we can make this easier is with what is called attributes. If we want to put the name and age of students as attributes instead of elements we do it like this:
- Code:
-
<student name="James" age="16">
</student>
which is another allowed way to do it!
Then it looks kinda silly to have a start part and an end part with nothing inside (although its still totally proper XML) but we can make it a bit shorter:
- Code:
-
<student name="James" age="16"/>
Note that we remove the ending tag and simply put the slash at the and of the start tag.
Now we can write the students list much more compactly:
- Code:
-
<class>
<student name="James" age="16"/>
<student name="Henry" age="17"/>
<student name="Joe" age="16"/>
</class>
All XML is, is a way to write down information, any kind of information! It's meant to be both readable by humans and by computers!
When you have XML with the purpose of informing the computer of something specific, like how we inform it of types of compounds, the program expects the XML to look in a specific way. It might expect the first element to be an element called "Compounds" then with a variable number of elements inside called "Compound" and then for each of those elements to have two elements called "Looks" and "Functionality" each with some attributes for model size, molecular weight etc.
The task I suggested for you was to write the XML files that our programming GUI library wants to read, which are a number of different XML structures that it needs for different things!
Questions?