XML in 5 minutes

XML stands for eXtensible Markup Language. It’s a language with no predefined words, that isn’t capable of doing anything, and has had a huge impact on how various applications work, and I predict will have a huge impact on how programs and web applications are developed in the coming years? “If it doesn’t do anything, how is this possible?” you may be thinking. The reason is because XML can be understood by a variety of languages, such as Javascript, PHP, and Java, just to name a few. It acts as a bridge between these languages to transfer data between. The best thing about XML is that it is also incredibly easy to learn. So, here is a quick tutorial to get you started in understanding XML.

The Beginning

every XML document (just a text file saved with the *.xml extension) Starts with this line:
<?xml version="1.0" encoding="ISO-8859-1"?>

simple right? moving on:

Understand Markup Tags

XML is made up of markup tags. there are no pre-defined tags, you just use whatever your want. here is an example:

<tag> info about the tag </tag>

unlike HTML, every opening tag must have a closing tag.

Markup tags can have children, or they can have attributes. It is usually preferable to use child tags over attributes. Let’s make an example out of one of the product from Mbare:

With Attributes:

<product name="painted tin lion" price="36"></product>

With child tags:

<product>
<name> painted tin lion </name>
<price> 36 </price>
< /product>

child tags can have their own children as well. On Mbare, every product has a category and a subcategory, let’s see how that would look if we added it to the XML markup:

<product>

<category> Painted Tin

<subcategory> Animals </subcategory>

</category>

<name> painted tin lion </name>
<price> 36 </price>
< /product>

And there you go! no you know enough to write XML documents! As for how it works within other languages, well, that’s another article for another day.

One Response to “XML in 5 minutes”

  1. [...] My linkbait: 7 tips to supercharge your adwords CTR Planning your first Web Site Keeping the user in mind XML in 5 minutes [...]

Leave a Reply