XML with CSS – Presentation of a simple page

After writing some articles about XAML, I have decided to go a little deeper in XML. Actually going deeper into XML is quite a challenge, due to the fact that XML is considered a meta-language and thus it is quite simple with straight forward logic. Thus, I have decided to present a simple XML example, with the usage of CSS. So, I need 2 files – a XML file and a CSS file. In the XML file I put the data, within tabs as I would like it to be structured. In the CSS file I put information about how it should look like. So, this is the XML file:

As you notice, we have four universities. In order to present it in XML, I have put the information for each university between tags <university></university>. The four universities are put between tags <universities></universities>.  The good thing about XML is that you understand the idea of the content really quickly, if the format is done correctly. Thus, you need just a quick look to understand the essence of the code and what does it present. A quick note – on the second line, you notice immediately that this file uses something from a file, named “VitoshEducation.css”. What does it use? It takes information about the styles from this file. This is the CSS file content:

What does it do? It simply tells the browser what to do, when it sees some of the XML elements. Thus, Whenever it sees “major” tag, the browser writes “Major: ” as in the file. At the closing of the tag <universities></universities> it writes “www.vitoshacademy.com” in italic. This is achieved through on line 4.

Here is how the XML file looks at your browser.

Enjoy the code!

About

VBA Developer